I'm doing practise on this website: https://dojotoolkit.org/reference-guide/1.9/dijit/layout/TabContainer-examples.html
Click on Run button in Programmatic Nested tabs section with following method:
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(); }
The pop-up screen takes a while to load. Then I try to click on 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.