support `within_frame` capybara method #25

wants to merge 2 commits into


None yet
3 participants

agibralter commented Apr 20, 2011

I added within_frame support to capybara-webkit. The method takes either a Fixnum or a String and sets the focus on a frame located by index or name/id respectively.

Working on frame handling. In terms of the QT code, the non-frame-rel…

specs pass with these changes (e.g. mainFrame() => currentFrame() and the new
injectJavascriptHelpers() code in WebPage.cpp).

It seems like the current JS+xpath implementation dives in to iframes already.
Is this desired behavior? I wonder if that works with x-domain iframes? I
doubt it...

Also, this design assumes that we only step one frame down at a time...

Lastly, I'm really not sure how QWebKit decides which frame is currentFrame().
For now, I'm hoping to be able to use the QWebFrame setFocus() method. This
may be a dead end though. We may have to have WebPage manually keep track of
the "current" frame.

agibralter commented on e677195 Apr 19, 2011

Hmm I think I'll use setFocus()... and in order to jump down and up multiple levels, we'll have to loop through all childFrames() and childFrames() of those frames and so on. We'll also have to keep track of how many levels down we go so that frame_focus_parent (maybe to be renamed frame_focus_original) knows how many levels to jump back up.


jferris commented Apr 20, 2011

Thanks; I pulled this in. I refactored the FrameFocus class a bit; here are the changes if you're interested: 3615624

@jferris jferris closed this Apr 20, 2011


agibralter commented Apr 23, 2011

Awesome, thank you! Sorry for my n00b c++ code... it's been like 6 years since I've touched C.

Is this supposed to yield the current page context to the caller? It looks like setFocus() in Qt only focuses the keyboard on that element.

Mostly I'm wondering if the page.find inside the within_frame supposed be scoped to the iframe?

within_frame id do

agibralter commented Feb 1, 2012

yeah I think page.find should work within that frame. That's what the tests in this commit test.

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