1

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 come message will be : no such element found

TylerH
  • 20,799
  • 66
  • 75
  • 101
pasindu sanje
  • 13
  • 1
  • 6

1 Answers1

2

You 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...:)

Saurabh Gaur
  • 23,507
  • 10
  • 54
  • 73