Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (29.3k points)

I'm using Selenium 2 WebDriver to test a UI that uses AJAX.

Is there a way to make the driver wait for a bit that the Ajax request will complete.

Basically, I have this :

d.FindElement(By.XPath("//div[8]/div[3]/div/button")).Click();

// This click trigger an ajax request which will fill the below ID with content.

// So I need to make it wait for a bit.

Assert.IsNotEmpty(d.FindElement(By.Id("Hobbies")).Text);

1 Answer

0 votes
by (50.2k points)

Try this out it will helps you 

var wait = new WebDriverWait(d, TimeSpan.FromSeconds(5));

var element = wait.Until(driver => driver.FindElement(By.Id("Hobbies")));

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...