Skip to content

Commit

Permalink
[fix] Issue 274 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ineverov committed Jul 18, 2018
1 parent b6cf8d0 commit 27fd00c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions features/iframes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Feature: IFrame interaction
Then I can locate the iframe by xpath
And I can see elements in an xpath iframe

Scenario: locate an iframe within section
Then I can locate the iframe within section
And I can see elements in the iframe within section

Scenario: interact with elements in an iframe
Then I can see elements in an iframe
And I can see elements in an iframe with capybara query options
Expand Down
13 changes: 13 additions & 0 deletions features/step_definitions/iframe_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
expect(@test_site.home).to have_xpath_iframe
end

Then('I can locate the iframe within section') do
@test_site.home.wait_for_section_for_iframe
@test_site.home.section_for_iframe.wait_for_iframe_within_section

expect(@test_site.home.section_for_iframe).to have_iframe_within_section
end

Then('I can see elements in an iframe') do
@test_site.home.my_iframe do |f|
expect(f.some_text.text).to eq('Some text in an iframe')
Expand All @@ -48,6 +55,12 @@
end
end

Then('I can see elements in the iframe within section') do
@test_site.home.section_for_iframe.iframe_within_section do |f|
expect(f.some_text.text).to eq('Some text in an iframe')
end
end

Then('I can see elements in an iframe with capybara query options') do
@test_site.home.my_iframe do |f|
expect(f).to have_some_text(text: 'Some text in an iframe')
Expand Down
12 changes: 7 additions & 5 deletions lib/site_prism/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Section
include ElementChecker
include Loadable
include ElementContainer
extend Forwardable

attr_reader :root_element, :parent

Expand Down Expand Up @@ -42,12 +43,13 @@ def visible?
page.visible?
end

def execute_script(input)
Capybara.current_session.execute_script(input)
end
def_delegators :capybara_session,
:execute_script,
:evaluate_script,
:within_frame

def evaluate_script(input)
Capybara.current_session.evaluate_script(input)
def capybara_session
Capybara.current_session
end

def parent_page
Expand Down
4 changes: 3 additions & 1 deletion test_site/html/home.htm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ <h2>People</h2>
<input type='submit' id='will_become_invisible' value='Will become invisible' style='display: block;'/>
<input type='submit' class='invisible' value='Invisible' style='display: none;'/>

<iframe id='the_iframe' name='the_iframe' src='my_iframe.htm'></iframe>
<div id="section_for_iframe">
<iframe id='the_iframe' name='the_iframe' src='my_iframe.htm'></iframe>
</div>
</body>
</html>
4 changes: 4 additions & 0 deletions test_site/pages/home.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ class TestHomePage < SitePrism::Page
iframe :index_iframe, MyIframe, 0
iframe :named_iframe, MyIframe, '[name="the_iframe"]'
iframe :xpath_iframe, MyIframe, :xpath, '//iframe[@name="the_iframe"]'

section :section_for_iframe, '#section_for_iframe' do
iframe :iframe_within_section, MyIframe, 0
end
end

0 comments on commit 27fd00c

Please sign in to comment.