Fenrir Fenrir - 11 months ago 181
Node.js Question

isElementPresent is not a function

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.

Answer Source

I have already answered here for this issue

For consistency with the other Selenium language bindings, WebDriver#isElementPresent() and WebElement#isElementPresent() have been deprecated. It has been completely removed from Selenium v3

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);