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

Handling iFrames #2

Open
jeffnyman opened this issue Aug 9, 2014 · 2 comments
Open

Handling iFrames #2

jeffnyman opened this issue Aug 9, 2014 · 2 comments

Comments

@jeffnyman
Copy link

This isn't so much an issue as it is a question about a potential issue. In using Capypage, what's the preferred idiom for accessing elements in an iframe? Or more generally the idea of the "within" construct from Capybara.

@sriv
Copy link
Member

sriv commented Aug 16, 2014

Sorry for the delay in getting back.

I guess this is an issue, particularly for iframe. I suspect that we might need to add a frame type to support within_frame of Capybara.

@selvakn : thoughts?

However, for other within constructs, would section suit your purpose? An example from the specs:

For a page that has

<div class="popup">
    <div class="title">Popup Title</div>
    <div class="details">Popup Details</div>
</div>

Define the Page Class with:

class PopupSection < Capypage::Section
    element :title, '.title'
end

class SamplePage < Capypage::Page
    set_url '/'

    section :popup, PopupSection, '.popup'
end

And then use it in the specs as:

popup = page.popup
expect(popup.title).to have_text('Popup Title') 

@jeffnyman
Copy link
Author

Yeah, I could see this working. A key thing, I believe, is ease of creating the element declarations in the page object so that you have to reference what you need in as few places as possible. So for example, an "ideal" might be something like this:

class MyPage < Capypage::Page
  within '#something' do
    element :some_element_1, '#element1'
    element :some_element_2, '#element2'
  end
end

and also this:

class MyPage < Capypage::Page
  within_frame '#something' do
    element :some_element_1, '#element1'
    element :some_element_2, '#element2'
  end
end

In these cases, everything I need to understand about the page, and the elements within it, can be understood solely in the context of that page. That said, I put "ideal" in quotes because that's purely my opinion. I'm still learning Capybara so I'm not sure what is and isn't possible with these context blocks.

@selvakn selvakn added ready and removed ready labels Sep 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants