Skip to content

Commit

Permalink
Merge pull request cheezy#486 from StephenTurley/page-section-present
Browse files Browse the repository at this point in the history
ActiveSupport causes `present?` to be redefined on `PageObject`
  • Loading branch information
jkotests authored Sep 5, 2019
2 parents 850d775 + c767054 commit 4bb675b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.4.1
ruby-2.4.6
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
sudo: required
dist: trusty
rvm:
- 2.2.7
- 2.3.4
- 2.4.1
- 2.4.6
- 2.5.5
- 2.6.3
cache: bundler
addons:
chrome: stable
Expand All @@ -14,4 +14,4 @@ before_script:
script: bundle exec rake $RAKE_TASK
env:
- RAKE_TASK=spec
- RAKE_TASK=features
- RAKE_TASK=features
10 changes: 2 additions & 8 deletions features/support/persistent_browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,25 @@ def self.is_remote?(target)
def self.watir_browser(target)
if is_remote?(target)
Watir::Browser.new(:remote,
:http_client => client,
:url => url,
:desired_capabilities => desired_capabilities)
else
browser = target.gsub('local_', '').to_sym
Watir::Browser.new browser, :http_client => client
Watir::Browser.new browser
end
end

def self.selenium_browser(target)
if is_remote?(target)
Selenium::WebDriver.for(:remote,
:http_client => client,
:url => url,
:desired_capabilities => desired_capabilities)
else
browser = target.gsub('local_', '').to_sym
Selenium::WebDriver.for browser, :http_client => client
Selenium::WebDriver.for browser
end
end

def self.client
Selenium::WebDriver::Remote::Http::Persistent.new
end

def self.capabilities(browser, version, platform, name)
caps = Selenium::WebDriver::Remote::Capabilities.send browser
caps.version = version
Expand Down
7 changes: 7 additions & 0 deletions lib/page-object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@ def save_screenshot(file_name)
platform.save_screenshot file_name
end

#
# Check if root element exists and is visible
#
def present?
root.present?
end

def self.register_widget(widget_tag, widget_class, base_element_tag)
Widgets.register_widget(widget_tag, widget_class, base_element_tag)
end
Expand Down
13 changes: 13 additions & 0 deletions spec/page-object/page-object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ class Foo; def bar; :bar_called; end; private; def baz; end; end
expect(watir_page_object).not_to respond_to :baz
expect(watir_page_object.bar).to eq :bar_called
end

end

context 'when sent present?' do
let(:element) { double }
it 'should ignore the ActiveSupport implementation' do
# simulate ActiveSupport being mixed in
allow_any_instance_of(Object).to receive(:present?)

expect(element).to receive(:present?)
watir_page_object.instance_variable_set(:@root_element, element)
watir_page_object.present?
end
end
end

Expand Down

0 comments on commit 4bb675b

Please sign in to comment.