最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to fix iframes not working with Microsoft Edge? - Stack Overflow

programmeradmin2浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 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...:)

发布评论

评论列表(0)

  1. 暂无评论