gpt4 book ai didi

javascript - 使用 NightwatchJS 将焦点更改为父元素

转载 作者:太空宇宙 更新时间:2023-11-04 01:06:33 26 4
gpt4 key购买 nike

可以使用 .frame JSON Wire Protocol 调用更深入地进入 DOM 树,但我还没有找到通过 DOM 树向上移动的方法。

    module.exports = {
"Enter and exit iframes in tree" : function(browser){
browser
//Currently focus is at top level.
.frame('iframeOne')
//Focus is now enters inner frame iframeTwo
.frame('iframeTwo')

//Attempt to move to frame directly
.frame('iframeOne')
//Selenium Error 'no such frame'

//Attempt to move focus up to iframeOne by searching from root.
.element('id', 'iframeOne', function(e){
browser.frame(e.value);
}
//Selenium Error 'no such element'

}

有一个 JSON Wire Protocol 调用框架/父级,可以向上移动到父元素,但 NightWatchJS 目前不支持它。如有任何建议,我们将不胜感激。

最佳答案

在当前的二进制版本中,您需要使用switchToDefaultContent命令。在 Java 中,这表现为 driver.switchTo().defaultContent()。这将带您到框架层次结构的顶部,您可以沿着树向下导航到您需要的框架。

“导航到父框架”有线协议(protocol)是全新的。在撰写本文时,大约需要几天时间。在撰写本文时,还没有发布的服务器实现可以理解该有线协议(protocol)端点。 Firefox 驱动程序直到最后一天左右才实现它。 IE 驱动程序的工作尚未开始。除了 Java 之外,它尚未在任何语言绑定(bind)中实现,并且仅在源代码树中实现;它尚未以二进制形式发布。如果您有耐心,将来就可以使用(没有可用的时间表,所以不要问),只是现在还没有。

关于javascript - 使用 NightwatchJS 将焦点更改为父元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22392992/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com