Reputation: 231
i wanted the driver to wait until a element is visible or present, but it is simply not working! the following code
it('shows events in "Event overview"', function(){
driver.findElement(By.css('#bs-example-navbar-collapse-1 > ul > li:nth-child(2) > a')).click();
driver.wait(function () {
return driver.isElementPresent(By.css('body > div.container > div > div.events-container.ng-scope > div:nth-child(1) > div.row.row-event.detailed-view > div.col-xs-9.col-sm-9.col-md-10'));
}, 3000);
});
gives me the following error
driver.isElementPresent is not a function
why? i copied the answer from here: Selenium WebDriver wait till element is displayed. other answers dont work either. should i show more of my code? im working on a client project and i dont want to publish the name of the client.
Upvotes: 2
Views: 2312
Reputation: 23825
I have already answered here for this issue
So if you're using Selenium3
and want to wait until desire element present, you should try using webdriver.until
as below :-
const until = webdriver.until;
var el = driver.wait(until.elementLocated(By.css('body > div.container > div > div.events-container.ng-scope > div:nth-child(1) > div.row.row-event.detailed-view > div.col-xs-9.col-sm-9.col-md-10')), 3000);
Upvotes: 6
Reputation: 2267
try the following:
return driver.findElements(By.css('body > div.container > div > div.events-container.ng-scope > div:nth-child(1) > div.row.row-event.detailed-view > div.col-xs-9.col-sm-9.col-md-10')).size() != 0;
Upvotes: -1