我正在使用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"). clickIf 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")更多推荐
发布评论