Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for frames/iframes #116

Open
aik099 opened this issue Feb 6, 2015 · 8 comments
Open

Support for frames/iframes #116

aik099 opened this issue Feb 6, 2015 · 8 comments

Comments

@aik099
Copy link
Member

aik099 commented Feb 6, 2015

Idea is to allow specifying frame/iframe name where element is located so that when somebody wants to access it an automatic switch to that frame happens and then switch back to original window/frame happens.

Possible implementations:

  • have inheritable @frame('test-name') or @frame('name' => 'test-name') annotation
  • have frame parameter for @find-by annotation (e.g. @find-by('id' => 'test-id', 'frame' => 'test-name'))

When used then:

  • current frame will be changed using switchToFrame method of Mink
  • a search will be made for an element
  • current frame is changed back to what it was

If was used on element container (sub-class of AbstractElementContainer, that was called HtmlElement before), then there is no need to specify frame/iframe on each element in this container because they'll be searched within container located in another frame/iframe anyway.

Egde cages:

  • nested framesets - I think Mink should be handling that already
  • frames/iframes in another window/tab - I think it's out of library scope because user can switch window before doing element search
@aik099 aik099 added this to the 1.1.0 milestone Feb 6, 2015
@evangelion1204
Copy link
Contributor

@frame sounds better to me else @find-by might get too complex and an extra annotation is easier to spot.

@evangelion1204
Copy link
Contributor

Just thinking about a possible implementation should we either enhance the DefaultElementLocator or create a new FrameElementLocator? The Factory could either return a Default or Frame depending on Property

@aik099
Copy link
Member Author

aik099 commented Apr 3, 2015

The default element locator can handle that. Nobody really restricts one element locator to operate only on one annotation.

@evangelion1204
Copy link
Contributor

In that case we need to access either the session or the driver itself to switch to Frame. Either we put it as part of the Locator or as part of the ISearchContext.

@aik099
Copy link
Member Author

aik099 commented Apr 3, 2015

No need. The search context is a real element (if I'm not mistaken), not a proxy. When we switch a frame and find an element there, then the returned element reference (inside Mink) contains (that needs to be tested) the frame where element was found. So even if you switch the frame, the element retrieved earlier should still act as being inside a frame and all subsequent findAll calls from locator should honor that.

@evangelion1204
Copy link
Contributor

I tested it, the element is found. But accessing it and changing the value will force selenium to search for the element again to alter the value resulting in a not found when switching back initially.

This means that we either need to hook on every driver access (location of the element) and switch the target frame or the implementation itself needs to be done in Mink and its drivers.

@aik099 aik099 removed this from the 1.1.0 milestone Apr 8, 2015
@aik099
Copy link
Member Author

aik099 commented Apr 8, 2015

You're correct. Mink only retains XPATH of element found via the Driver (e.g. Selenium, Sahi). Then this xpath is used to perform all further actions (even finding sub-elements).

To make this happen we need to:

  1. store frame handle (driver specific frame identifier) next to WebElement
  2. before every operation switch frame to needed one (if they differ)
  3. after every operation switch frame back (if needed)

Doesn't sound like an easy task. Let's postpone this for now.

@aik099
Copy link
Member Author

aik099 commented Mar 1, 2016

Interesting idea posted here: yandex-qatools/htmlelements#56 (comment)

So we switch to frame once > do the stuff > switch back. Since we do it outside of the elements no need to switch back/forth on each element query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants