问题描述
我正在尝试使用 element.flood.io 中的 browser.switchTo().frame(0)
方法在页面上的 iFrame 之间切换。有两个 iframe - xpath 位置是 //body[1]/form[3]/div[5]/iframe[1] 和 //body[1]/form[3]/div[2]/iframe[1] ]
我似乎无法与页面上的任一框架进行交互。到目前为止,我已经尝试过:
step('3. Switch frame',async browser => {
await browser.wait.Until.abletoSwitchToFrame()
await browser.switchTo().frame(0)
我也尝试过使用 xpath。
step('3. Switch frame',async browser => {
let iframe = await browser.findElement(By.xpath('//body[1]/form[3]/div[2]/iframe[1]'))
let newbrowser = await browser.swicthto().frame(iframe)
这个链接应该有帮助,但我不认为它是:
https://element.flood.io/docs/api/browser#switchto
解决方法
您可以使用:
await browser.wait(Until.ableToSwitchToFrame(frame id))
https://element.flood.io/docs/api/waiters#untilabletoswitchtoframeframe