我想使用selenium web驱动程序找到按钮ID。我试过这段代码:
@Test
public void hello()
{
RemoteWebDriver driver = BrowserFactory.getDriver("chrome", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
driver.get("http://jenkins.mws.com:8080");
WebDriverWait waitPage = new WebDriverWait(driver, 20);
WebElement until = waitPage.until(ExpectedConditions.presenceOfElementLocated(By.id("ready")));
if (until.isDisplayed()){
System.out.println("button is displayed");
}
}
但我得到Timed out after 20 seconds waiting for presence of element located by: By.tagName: button
以下是我要测试的代码:
我能找到标签按钮吗?
答案 0 :(得分:4)
<button>
位于iFrame
内。首先切换到iFrame driver.switchTo().frame("iwg-game-full");
,然后尝试。