简体   繁体   中英

Selenium-Webdriver, driver.findElement(…).getLocation is not a function, why?

I am trying to call .getLocation() on Selenium element like this code below.

const webdriver  = require('selenium-webdriver');

const driver = new webdriver.Builder()
        .forBrowser('firefox')
        .build();

driver.findElement(webdriver.By.css('.xxxx'))
        .getLocation()
        .then(l => {
           console.log('got a position');
           console.log(l);
        });

But i got

Unhandled promise rejection (rejection id: 1): TypeError: driver.findElement(...).getLocation is not a function

What did i do wrong?. Or do i need to import some other librabry?

Thanks!

There is no getLocation() for WebElement in JavaScript. You have getRect()

driver.findElement(webdriver.By.css('.xxxx')).getRect()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM