我在Internet上查找了许多资源,但我一直在努力寻找答案,以获取如何通过 Firefox 网络在 NodeJS 中正常工作的方法司机。对于我要怎么做的任何指导,我将不胜感激。我知道我要完成这项工作并非遥不可及。还是我写的应该有效,这是我的xpath出错了?
仔细阅读这篇文章,看来我需要明确等待,因为隐式等待不会等待元素出现。通过在搜索框中输入值,它会动态显示。
尝试1
this.driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
this.driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
this.driver.manage().timeouts().implicitWait = timeSpan.FromSeconds(1);
这些似乎在Node JS中不起作用,并导致各种错误,例如
TypeError:未指定超时
driver.manage(...)。timeouts不是函数
尝试2
不返回错误,但也不等待。 默默地失败。
//In my When construct
WaitForThing(this.driver)
//Outside the When construct at the top of the stepdefinition.js
async function WaitForThing(driver){
await driver.wait(until.elementlocated(By.xpath("thexpath")),10000);
let theelementiwanttocheckfor = driver.findElement(By.xpath("thexpath"));
await driver.wait(Until.elementIsEnabled(theelementiwanttocheckfor ,15000));
};
我如何实例化firefox驱动程序:
this.driver = new seleniumWebdriver.Builder()
.forBrowser('firefox')
.build();