I want to test a site using selenium webdriver (java), but that site contains ajax and HTMLUnit does not see the ajax content.
Is there a 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
use Wait condition before interaction with element with must appear after ajax response.
WebDriverWait wait = new WebDriverWait(webDriver, 5);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("xpath_to_element")));
this makes webDriver to wait for your element during 5 secs. This question was asked earlier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With