【发布时间】:2019-11-23 02:21:20
【问题描述】:
我正在这个网站上练习:https://dojotoolkit.org/reference-guide/1.9/dijit/layout/TabContainer-examples.html
-
使用以下方法单击编程嵌套选项卡部分中的运行按钮:
WebElement productElement = null; List<WebElement> productElements= driver.findElements(By.cssSelector(div.section)); for(int i=0;i<productElements.size();i++) { String text = productElements.get(i).findElement(By.tagName("h2")).getText(); if (text.equalsIgnoreCase(tabName)){ productElement = productElements.get(i); break; } } return productElement; } public void clickRunButton(String tabName) { WebElement programmaticNestedtabs = findTab(tabName); WebElement runButton = programmaticNestedtabs.findElement(By.cssSelector("a.CodeGlassMiniRunner")); runButton.click(); } 弹出屏幕需要一段时间才能加载。然后我尝试点击 Tab 2:
WebDriverWait wait = new WebDriverWait(driver, 50);
driver.switchTo().frame(driver.findElement(By.tagName("iframe")));
dialog.findElement(By.xpath("//div[@class='dijitTabListWrapper dijitTabContainerTopNone dijitAlignCenter']//div[2]")).click();```
I got the StaleElementReferenceException when I run the code.
【问题讨论】:
标签: java selenium iframe staleelementreferenceexception