我想使用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
这是我要测试的代码:
http://pastebin.com/up29pSRQ
我可以找到标签按钮吗?
最佳答案
<button>
在iFrame
内部。首先切换到iFrame,然后尝试。