Watir Firefox Issue with iframe Handling
I'm experiencing an issue with Watir's iframe handling in Firefox. The issue does not occur in Chrome.
Environment:
- Watir Version: 7.3
- Selenium Version: 4.2
- Browser Version: Firefox 122.0.1 64-bit
- Browser Driver Version: geckodriver 0.34.0
- OS Version: Mac OS 14.2.1
Note: The issue exists on other OS and other version of watir and FF too.
Issue:When using methods like wait_until
or .html
on an iframe, I encounter a Watir::Exception::UnknownObjectException
.
Reproduction Steps:I've created a class TestFFIssueWatir
with two methods check_error_using_wait_until
and check_error_with_html
that demonstrate the issue.
In check_error_using_wait_until
, after using wait_until
on an iframe, only one operation can be performed on it. The second send_keys
operation fails.
In check_error_with_html
, after using .html
on an iframe, the iframe variable seems to get garbage collected and any subsequent operations on it fail.
Here's a simplified version of the code:
class TestFFIssueWatir def initialize @browser = Watir::Browser.new :firefox end def goto_website @browser.goto('https://demo.automationtesting.in/Frames.html') end def check_error_using_wait_until testIframe = @browser.body.iframe(id: 'singleframe') testIframe.wait_until(timeout: 10, &:present?) testIframe.input.send_keys('Hello, Universe!') testIframe.input.send_keys('Hello, Again!') end def check_error_with_html testIframe = @browser.body.iframe(id: 'singleframe') puts(testIframe.html) testIframe.input.send_keys('Hello, world!') endendtest_watir = TestFFIssueWatir.newtest_watir.goto_websitetest_watir.check_error_with_htmltest_watir.check_error_using_wait_until
Any help in resolving this issue would be greatly appreciated.
P.S: Since this seems like library issue, I have also posted this as Issue on repo too: Issue link
Basically, I am working on website that have lot of iframes. On selenium we have to use switch_to to switch to iframe. But watir provides us wrapper which let us use iframe like normal elements.
Everything was working fine on chrome. But we now need to run it on FF too.
And on firefox seems like for lot of method [wait, html] if we use it on iframe assigned variable; that variable becomes useless after that. We get Object not found issue.
Issue Details
- The issue is present on Firefox browser only; not on chrome.
- The issue is present on different OS as well as different versions of geckodriver.
- I have provided 2 methods to reproduce the issue. check_error_with_html and check_error_using_wait_until_fix
check_error_with_html
This method will demo FF issue with iframe handling. Case when .html type method are used on iframe, the variable(that stores the iframe) does not work.
Eg: On above if you uncomment test_watir.check_error_with_html and comment test_watir.check_error_using_wait_until_fix, then you will see the issue.Here after using testIframe.html I cannot use any method on testIframe.It will give Watir::Exception::UnknownObjectException. eg: testIframe.input.send_keys('Hello,
check_error_using_wait_until_fix
This method will demo FF issue with iframe handling when using method like wait_until. Here once you use wait_until say on iframe a, then you can use only one operation on it.Eg: below send_keys will fail on second attempt after that because we used wait_until on iframe.