guys I cannot find a solution of the clicking (unclicking) a checkbox placed in an alert window, modal pop-ups. We have three types pop-up: alert, confirm, prompt. In the confirm popup there is a checkbox. I want to check it using selenium webdriver and java language. There are functions handling these popups: dismiss(), accept(), sendKeys(), getText(). Is it possible to check the checkbox in popups? I hope, it's. Could anybody help me? thanks
You can do it with two ways
1)
driver.switchTo().alert();
driver.findElement(By.xpath("")).click();
Put your locator in above code
2)
If above doesn't work then as below:
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
driver.findElement(By.xpath("")).click();
driver.switchTo().window(parentWindowHandler); // switch back to parent window
If even that doesn't work check if there is any frame present, you need to switch to frame also
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.