空手道驱动程序与iframe的互动 [英] Karate Driver interaction with iframe
问题描述
在使用空手道驱动程序以及将数据输入到iframe中的字段中时遇到困难
Having difficulty with Karate Driver and inputing data into fields that are in an iframe
尝试将xpath和css选择器用于iframe,因此从理论上讲我可以切换到iframe并与之交互,而不会遇到任何麻烦.我可以找到iframe,但是不确定如何将上下文切换到iframe,这样场景就可以在iframe中继续进行.例如,将值输入iframe中的字段.
Have tried using xpath and css selectors to the iframe so I could theoretically switch into and interact with the iframe without any luck. I can find the iframe but I am unsure how to switch context to the iframe so the scenario can continue inside the iframe. For example inputting values into fields in the iframe.
请帮助:)
更新:可以成功切换到iframe,但现在遇到嵌套iframe的问题.
Update: Can successfully switch into an iframe but now running into an issue with nested iframe.
* switchFrame(0)
* click('.some-checkbox')
* switchFrame(0)
两个iframe都没有出色的CSS选择器.索引为0的第二个switchFrame不查找嵌套的iframe.
neither iframe has great css selectors. The second switchFrame with an index of 0 is not looking to the nested iframe.
推荐答案
我想您已经在这里看过文档: https://github.com/intuit/karate/tree/develop/karate-core#switchFrame
I guess you have seen the docs here: https://github.com/intuit/karate/tree/develop/karate-core#switchFrame
我承认这非常棘手.理想情况下,您应该为框架使用适当的CSS或ID选择器,这是我进行的测试中的实际工作示例.请注意, waitFor()
可能是您所缺少的,尤其是当< iframe>
是加载缓慢的膨胀软件时.
I admit this is very tricky. Ideally you have a proper CSS or ID selector to the frame and this is an actual working example from a test I have. Note that the waitFor()
may be what you are missing, especially when the <iframe>
is some slow loading bloatware.
* waitFor('.some-css-name iframe').switchFrame()
* click('.some-checkbox')
* switchFrame(null)
不幸的是,我发现这通常在以下驱动程序类型上效果最佳: chrome
和 chromedriver
And unfortunately I have found that this tends to work best on driver type: chrome
and chromedriver
这篇关于空手道驱动程序与iframe的互动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!