Varis Darasirikul
Varis Darasirikul

Reputation: 4177

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!

Upvotes: 2

Views: 2674

Answers (2)

sarang S.U
sarang S.U

Reputation: 1

Always check weather your screen size is 100% , which can lead to issue in locating the element .

Upvotes: 0

Guy
Guy

Reputation: 50899

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

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

Upvotes: 6

Related Questions