Problems with HTMLUnit WebDriver with Ajax

I want to test the site using selenium webdriver (java), but this site contains ajax and HTMLUnit does not see the contents of ajax.

Is there any workaround?

Example:

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 
+5
source share
1 answer

use a wait condition before interacting with element c should appear after ajax response.

WebDriverWait wait = new WebDriverWait(webDriver, 5);
 wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("xpath_to_element")));

this makes webDriver wait for your item for 5 seconds. This question has been asked before.

+5
source

All Articles