Krz*_*zys 5 java ajax webdriver htmlunit
我想使用selenium webdriver(java)测试一个站点,但该站点包含ajax,HTMLUnit没有看到ajax内容.
有解决方法吗?
例:
WebDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
//login into your account
this.login(driver);
//click on edit Profile Link into an ajax-loaded tab
driver.findElement(By.id("editProfile")).click();
//Result: org.openqa.selenium.NoSuchElementException
Run Code Online (Sandbox Code Playgroud)
在与元素交互之前使用等待条件必须在ajax响应之后出现.
WebDriverWait wait = new WebDriverWait(webDriver, 5);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("xpath_to_element")));
Run Code Online (Sandbox Code Playgroud)
这使得webDriver在5秒内等待你的元素.之前曾问过这个问题.
| 归档时间: |
|
| 查看次数: |
3186 次 |
| 最近记录: |