webdriverIO 5, iframe 元素 'id' 未给出时如何切换到 iframe?
webdriverIO 5, how to switch to iframe when its element 'id' not given?
frame html code:
<iframe title="frame report" class="ReportViewer__iframe" src="/yesyyy.aspx?reportId=145&ts=1550681978158&bgcolor=#f8f9fb" width="100%" height="100%"></iframe>
标题和 class 名称定位器的脚本均失败 -- 'ERROR webdriver: Request failed due to Error: no such frame'
使用以下代码。
driver.switchTo().defaultContent();
WebElement frameXpath = driver.findElement(By.xpath("//iframe[@title='frame report']"));
driver.switchTo().frame(frameXpath);
得到解决方案,需要通过可用定位器(标题和 css class)的 iframe object
browser.switchtoframe($('.report__iframe'))
frame html code:
<iframe title="frame report" class="ReportViewer__iframe" src="/yesyyy.aspx?reportId=145&ts=1550681978158&bgcolor=#f8f9fb" width="100%" height="100%"></iframe>
标题和 class 名称定位器的脚本均失败 -- 'ERROR webdriver: Request failed due to Error: no such frame'
使用以下代码。
driver.switchTo().defaultContent();
WebElement frameXpath = driver.findElement(By.xpath("//iframe[@title='frame report']"));
driver.switchTo().frame(frameXpath);
得到解决方案,需要通过可用定位器(标题和 css class)的 iframe object browser.switchtoframe($('.report__iframe'))