TypeError: driver.isElementPresent is not a function

前端 未结 2 1170
温柔的废话
温柔的废话 2021-01-05 08:06

I am attempting to write a node function that logs into a website and am having trouble getting it to work. I am trying to wait for the page to load using the isElem

2条回答
  •  被撕碎了的回忆
    2021-01-05 08:42

    For consistency with the other Selenium language bindings, WebDriver#isElementPresent() and WebElement#isElementPresent() have been deprecated.

    If you're using Selenium 3, you should try using findElements instead to determine element present or not as below :-

    driver.findElements(By.id('email')).then(found => !!found.length);
    

    Or if you want to wait until desire element present, you should try using webdriver.until as below :-

    const until = webdriver.until;
    
    var user = driver.wait(until.elementLocated(By.id('email')), timeout);
    user.sendKeys(username);
    

提交回复
热议问题