Steps that I have to perform
- I have a website (www.xyz.com)
- I successfully opened it through Firefox.
- In the page, there is a google icon (image) which I am suppose to click
- After clicking the google icon, a pop up to enter user name and password appears
I am able to click icon but am not able to get the pop up executed through the selenium code.
It stops at clicking the icon only.
I want the pop up to be opened through my code.
I am using window handles to handle pop up.
Can some one help me in this?
I am trying below steps:
1 Go to http://www.rentedroofs.com/dashboard/#/welcome
2 Now try to click Fb or google and try to work on the pop up .
WebElement element1 = driver.findElement(By.xpath("//html/body/div[3]/md-dialog/md-dialog-content/div/div/div/button[1]"));
element1.click();
String parentWindowHandler = driver.getWindowHandle(); // Store your parent window
String subWindowHandler = null;
Set<String> handles = driver.getWindowHandles(); // get all window handles
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler); // switch to popup window
I tried -
driver.get("http://www.rentedroofs.com/");
WebElement element = driver.findElement(By.xpath("/html/body/section[2]/header/div/div/div/div/a"));
element.click();
Thread.sleep(10000);
String handle= driver.getWindowHandle();
System.out.println(handle);
WebElement element1 = driver.findElement(By.xpath("//html/body/div[3]/md-dialog/md-dialog-content/div/div/div/button[1]"));
element1.click();
Set handles = driver.getWindowHandles();
System.out.println(handles);
for (String handle1 : driver.getWindowHandles()) {
System.out.println(handle1);
driver.switchTo().window(handle1);
}
But this is not opening the FB pop UP.