我正在尝试使用JavaScript代码来确定在我的e2e测试的其余部分中使用哪个选择器,问题是我所依赖的By.js()应该返回一个元素或元素列表
PS:我尝试将回调函数作为参数发送给By.js()函数,但没有用。
selenium-webdriver 4.0.0
driver.wait(webdriver.until.elementLocated(webdriver.By.js(function (selectors) {
let element = null;
for (let i in selectors) {
if (element = document.querySelector(selectors[i])) {
return element;}
}
return null;
}, ["#e1", "#e2", "#e3"])), 10000, "no random element found"))
.then(element => {
console.log(PRINT THE SELECTOR THAT WAS USED TO FIND THE ELEMENT);
})