Watir / Selenium2 Nothing happens after clicking on an element inside iframe in Internet Explorer 9

I am writing autotests with Watir-WebDriver and Ruby 1.9.2 on Ubuntu for the web. I have an iframe with multiple elements. I need to click on the items and check what happens. <iframe> as follows:

 <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 a menu. But when I click the button using watir-webdriver, nothing happens as if it didn't click. Watir does not print any exceptions, but do not click a button.

This issue persists only for Internet Explorer. There are no problems for Firefox and Chrome. My code looks like this:

 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 returns "some_class" . This means that the element is recognized, but nothing happens.

+4
source share
2 answers

Have you tried using the javascript command?

For instance:

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

If this does not work, try debugging using IRB.

PS: I would write it as follows:

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

Please try this code.

 browser.iframe(:id, "iframe").button (: id, "id_button").click 

if you need more information check this link

http://wiki.openqa.org/display/WTR/Frames

+1
source

Source: https://habr.com/ru/post/1432789/


All Articles