Reputation: 809
I have a page that has a drop down with a list of clients. Because there are a lot of clients (e.g. 500) it takes about 20seconds to load all of it. I want to test this loading and check if a certain client is present at a certain time. Here is my code:
browser.sleep(5000);
SearchPage.clientDropDownButton.click();
SearchPage.clientSearchTextbox.sendKeys('company500');
//companies not loaded yet at this point.
expect(SearchPage.clientFirstOption.isPresent()).toBeFalsy();
After 5 seconds, the code will start typing in the company name, but because the clients are not done loading, I'm expecting the element to not be present and that it will return false. The problem is that it seems isPresent()
waits until clientFirstOption
element is present before elvaluating if its present or not. It doesn't do the checking immediately and pass the test. How can I get the isPresent method to check immediately?
Upvotes: 0
Views: 430
Reputation: 2384
Have you modified the implicitlyWait value to be something other than 0? If so, drop it back down to 0 before calling isPresent()
:
browser.sleep(5000);
SearchPage.clientDropDownButton.click();
SearchPage.clientSearchTextbox.sendKeys('company500');
browser.manage().timeouts().implicitlyWait(0);
expect(SearchPage.clientFirstOption.isPresent()).toBeFalsy();
Upvotes: 3