SeleniumLibrary
SeleniumLibrary copied to clipboard
Fix and cleanup logic related to frames
There are currently several problems with handling frames that should be resolved. Some of these problems are already covered by existing issues, but this new issue list all these highly related problems in one place. The whole frame handling logic should be rewritten and all these problems resolved at the same time.
Page Should (Not) Containsearches text from frames, but only searches from one level and not from sub frames (#98)- Other keywords don't look inside frames at all. This includes
Page Should (Not) Contain ElementandCurrent Frame Should (Not) Contain. (#98) Page Should (Not) Containinternally selects the main frame, disabling earlierSelect Framecalls.(#201)- We should see could we deprecate all
Current Frame ...keywords. It would be better that after selecting a frame, all subsequent keywords would operate in the frame. This may actually already be the case, except withPage Should (Not) Containwhich looks from the root (see 3. above). - If all keywords operate on the selected frame,
Page Shouldis pretty misleading wording. Should we consider renaming these keywords likePage Should Contain -> Text Should Be Present,Page Should Contain Element -> Element Should Be Present?
Additionally to the problems already listed, there is a similar problem with the Frame Should Contain Keyword, the driver is switched back to the default context, which is undesirable when working on sub frames. (expected to end up at the window/frame that we started from, not the main window).
Any update on this one?
There is not progress for this issue because no-one has seen it enough important to invest time.
@pekkaklarck Do we have some progress in this issue :)
Nothing has happened since my last comment.
Hi, My problem is related to frames management with RFW but I don't know if it's the right place to discuss about it.
I'm using RFW 3.2.2 with Python 3.9 on Windows with FF or Chrome.
I'm working on a app with lots of frames which contains iframes, some are dynamically created...
- Page
- Frame1
- IFrame1
- IFrame2 (not created yet)
- Frame2
- Frame3
- Frame1
Select Frame Frame1 is OK Select Frame IFrame1 is OK (Displays a form) Input Text Name Hello is OK Click Button Save (button in the IFrame1) is OK (by clicking this button, the app dynamically creates a new iframe IFrame2) Unselect Frame Select Frame IFrame2
IFrame2 can't be selected. If I execute javascript to get the reference, I can get it but I then get the StaleReferenceException if I try to select it through Select Frame
Any ideas?
Ok, I found the solution. As I read somewhere in another issue, Unselect Frame returns you to the top parent, so the solution was to look for the elements from the beginning.
So after the Unselect Frame, I now do:
Select Frame Frame1 Select Frame IFrame2
and everything works like a charm.
But the issue about the top parent is annoying because really not intuitive.
Sorry to have bothered you for so little things but I was going crazy...
Thanks for the work, RFW is really interesting.
JC
Yes, we do not keep track of the frames and Selenium API only allows to select top most page.
If that is not documented, then it should be fixed.
Indeed, in the docs (https://robotframework.org/Selenium2Library/Selenium2Library.html#Unselect%20Frame) it is written:
- Unselect Frame : Sets the main frame as the current frame. In practice cancels the previous Select Frame call.
It should be better to say it cancels all the previous Select Frame calls and sets you to the top, not the direct parent.
All is a little word, but it matters :-D
JC
Yes, that could be enhanced. Would you like make a PR to fix it?
Please remember that Selenium2Library is not maintained and correct project is https://github.com/robotframework/SeleniumLibrary#keyword-documentation (Although the text is same in both)