Change iframe works fine with Firefox webdriver and Chrome web driver but not with the Microsoft Edge Driver. All the other tests are working fine in Edge, but not changing iframes. I updated the Edge driver and Windows 10 because it's a known issue, but this still has not resolved my problem. Is there any other way to fix this?
driver.switchTo().defaultContent();
driver.switchTo().frame("settingiframe");
driver.findElement(By.id("LibraryConfigurations")).click();
Out e message will be : no such element found
Change iframe works fine with Firefox webdriver and Chrome web driver but not with the Microsoft Edge Driver. All the other tests are working fine in Edge, but not changing iframes. I updated the Edge driver and Windows 10 because it's a known issue, but this still has not resolved my problem. Is there any other way to fix this?
driver.switchTo().defaultContent();
driver.switchTo().frame("settingiframe");
driver.findElement(By.id("LibraryConfigurations")).click();
Out e message will be : no such element found
Share Improve this question edited Feb 7, 2017 at 2:56 TylerH 21.1k79 gold badges79 silver badges114 bronze badges asked Jul 5, 2016 at 11:29 pasindu sanjepasindu sanje 131 gold badge1 silver badge6 bronze badges 3- check this...stackoverflow./questions/10879206/… – Amol Chavan Commented Jul 5, 2016 at 11:48
- Code is working on normal browsers but not in edge... – pasindu sanje Commented Jul 5, 2016 at 12:09
- I suggest, first try finding frame element and then try switching to it. – Amol Chavan Commented Jul 5, 2016 at 12:14
1 Answer
Reset to default 2You need to implement WebDriverWait
to wait for frame available then switch like as below :-
WebDriverWait wait = new WebDriverWait(driver,20);
driver.switchTo().defaultContent();
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("settingiframe"));
//after successfully switching to frame you need to wait until element to be clickable
WebElement el = wait.until(ExpectedConditions.elementToBeClickable(By.id("LibraryConfigurations")));
el.click();
Note :- The above code will wait
for a given frame
up to 20 seconds. If the frame
will be available within given time, it will switch to the given frame
. Otherwise, it will throw TimeoutException
.
Hope it will help you...:)