我正在尝试在 Selenium 元素上调用 .getLocation(),如下代码所示。
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);
});
但我有
Unhandled promise rejection (rejection id: 1): TypeError: driver.findElement(...).getLocation is not a function
我做错了什么? 或者我需要导入其他库吗?
谢谢!
最佳答案
JavaScript 中没有用于 WebElement
的 getLocation()
。你有getRect()
driver.findElement(webdriver.By.css('.xxxx')).getRect()
关于javascript - Selenium-Webdriver, driver.findElement(...).getLocation 不是一个函数,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53312388/