Watir / Selenium2在Internet Explorer 9中单击iframe内的元素后,没有任何反应(Watir/Selenium2 Nothing happens after cli

系统教程 行业动态 更新时间:2024-06-14 16:57:18
Watir / Selenium2在Internet Explorer 9中单击iframe内的元素后,没有任何反应(Watir/Selenium2 Nothing happens after clicking on an element inside iframe in Internet Explorer 9)

我正在使用Ubuntu上的Watir-WebDriver和Ruby 1.9.2在网上编写自动测试。 我有几个元素的iframe。 我需要点击这些项目并检查发生了什么。 <iframe>看起来像:

<iframe id="iframe" align="top" some_attribute="some_attribute"> <html> <head> <title> Some title </title> </head> <body> <div> <button id="id_button" type="button" class="some_class"/> </div> </body> </html> </iframe>

当我点击按钮时,它应该创建菜单。 但是当我用watir-webdriver点击按钮时,没有任何反应,就好像他没有按下。 Watir不打印任何例外,但不要按下按钮。

此问题仅在Internet Explorer中存在。 对于Firefox和Chrome,没有问题。 我的代码如下所示:

browser = Watir :: Browser.new (: remote,: url => "http://some_ip:4444/wd/hub",: desired_capabilities =>: internet_explorer) browser.goto ("http://some_http.com") browser.iframe.button (: id, "id_button"). click

如果我写

browser.iframe.button(: id, "id_button").attribute_value("class")

它返回"some_class" 。 这表明该物品已被识别,但仍然没有任何反应。

I'm writing autotests with Watir-WebDriver and Ruby 1.9.2 on Ubuntu for the web. I have some iframe with several elements. I need to click on the items and check what happens. The <iframe> looks like:

<iframe id="iframe" align="top" some_attribute="some_attribute"> <html> <head> <title> Some title </title> </head> <body> <div> <button id="id_button" type="button" class="some_class"/> </div> </body> </html> </iframe>

When I click on the button, it should create the menu. But when I click on the button with watir-webdriver, nothing happens, as if he did not pressed. Watir don't print any exceptions, but do not press the button.

This problem persists only for Internet Explorer. For Firefox and Chrome, there is no problem. My code looks like:

browser = Watir :: Browser.new (: remote,: url => "http://some_ip:4444/wd/hub",: desired_capabilities =>: internet_explorer) browser.goto ("http://some_http.com") browser.iframe.button (: id, "id_button"). click

If I write

browser.iframe.button(: id, "id_button").attribute_value("class")

It's returning "some_class". This indicates that the item is recognized, but still nothing happens.

最满意答案

你有没有尝试过使用JavaScript命令?

例如:

browser.iframe.button(:id, "id_button").fire_event("onclick")

如果这不起作用,请尝试使用IRB进行调试。

PS:我会写下如下:

browser.iframe(:id, /iframe/).button(:id, /button/).fire_event("onclick")

Have you tried using a javascript command?

Eg:

browser.iframe.button(:id, "id_button").fire_event("onclick")

If that doesn't work, try debugging using IRB.

PS: I would write it as follows:

browser.iframe(:id, /iframe/).button(:id, /button/).fire_event("onclick")

更多推荐

本文发布于:2023-04-12 20:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/0e7e966af67a48015975455902981ddf.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有任何   单击   元素   Internet   Watir

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!