Skip to content

Commit

Permalink
mark known selenium-webdriver/geckodriver/marionette failrues as pending
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jan 3, 2017
1 parent d3231a9 commit e77471e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 19 deletions.
41 changes: 23 additions & 18 deletions lib/capybara/selenium/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,6 @@ def switch_to_window(handle)
browser.switch_to.window handle
end

# @api private
def find_window(locator)
handles = browser.window_handles
return locator if handles.include? locator

original_handle = browser.window_handle
handles.each do |handle|
switch_to_window(handle)
if (locator == browser.execute_script("return window.name") ||
browser.title.include?(locator) ||
browser.current_url.include?(locator))
switch_to_window(original_handle)
return handle
end
end
raise Capybara::ElementNotFound, "Could not find a window identified by #{locator}"
end

def within_window(locator)
handle = find_window(locator)
browser.switch_to.window(handle) { yield }
Expand Down Expand Up @@ -277,6 +259,29 @@ def no_such_window_error
Selenium::WebDriver::Error::NoSuchWindowError
end

# @api private
def find_window(locator)
handles = browser.window_handles
return locator if handles.include? locator

original_handle = browser.window_handle
handles.each do |handle|
switch_to_window(handle)
if (locator == browser.execute_script("return window.name") ||
browser.title.include?(locator) ||
browser.current_url.include?(locator))
switch_to_window(original_handle)
return handle
end
end
raise Capybara::ElementNotFound, "Could not find a window identified by #{locator}"
end

#@api private
def marionette?
(options[:browser].to_s == "firefox") && browser.capabilities.is_a?(Selenium::WebDriver::Remote::W3CCapabilities)
end

# @deprecated This method is being removed
def browser_initialized?
super && !@browser.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selenium/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def selected?

def disabled?
# workaround for selenium-webdriver/geckodriver reporting elements as enabled when they are nested in disabling elements
if driver.options[:browser].to_s == "firefox" && driver.browser.capabilities.is_a?(Selenium::WebDriver::Remote::W3CCapabilities)
if driver.marionette?
if %w(option optgroup).include? tag_name
!native.enabled? || (find_xpath("parent::optgroup")[0] || find_xpath("parent::select")[0]).disabled?
else
Expand Down
3 changes: 3 additions & 0 deletions lib/capybara/spec/session/accept_prompt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
end

it "should accept the prompt with a response" do
pending "selenium-webdriver/geckodriver doesn't support sending a response to prompts" if marionette?(@session)
@session.accept_prompt with: 'the response' do
@session.click_link('Open prompt')
end
expect(@session).to have_xpath("//a[@id='open-prompt' and @response='the response']")
end

it "should accept the prompt if the message matches" do
pending "selenium-webdriver/geckodriver doesn't support sending a response to prompts" if marionette?(@session)
@session.accept_prompt 'Prompt opened', with: 'matched' do
@session.click_link('Open prompt')
end
Expand All @@ -42,6 +44,7 @@


it "should return the message presented" do
pending "selenium-webdriver/geckodriver doesn't support sending a response to prompts" if marionette?(@session)
message = @session.accept_prompt with: 'the response' do
@session.click_link('Open prompt')
end
Expand Down
7 changes: 7 additions & 0 deletions lib/capybara/spec/session/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@

describe '#drag_to', requires: [:js, :drag] do
it "should drag and drop an object" do
pending "selenium-webdriver/geckodriver doesn't support mouse move_to" if marionette?(@session)
@session.visit('/with_js')
element = @session.find('//div[@id="drag"]')
target = @session.find('//div[@id="drop"]')
Expand All @@ -290,6 +291,7 @@

describe '#hover', requires: [:hover] do
it "should allow hovering on an element" do
pending "selenium-webdriver/geckodriver doesn't support mouse move_to" if marionette?(@session)
@session.visit('/with_hover')
expect(@session.find(:css,'.hidden_until_hover', visible: false)).not_to be_visible
@session.find(:css,'.wrapper').hover
Expand All @@ -306,6 +308,7 @@

describe '#double_click', requires: [:js] do
it "should double click an element" do
pending "selenium-webdriver/geckodriver doesn't support mouse move_to" if marionette?(@session)
@session.visit('/with_js')
@session.find(:css, '#click-test').double_click
expect(@session.find(:css, '#has-been-double-clicked')).to be
Expand All @@ -314,6 +317,7 @@

describe '#right_click', requires: [:js] do
it "should right click an element" do
pending "selenium-webdriver/geckodriver doesn't support mouse move_to" if marionette?(@session)
@session.visit('/with_js')
@session.find(:css, '#click-test').right_click
expect(@session.find(:css, '#has-been-right-clicked')).to be
Expand All @@ -328,18 +332,21 @@
end

it "should send special characters" do
pending "selenium-webdriver/geckodriver doesn't support complex sets of characters" if marionette?(@session)
@session.visit('/form')
@session.find(:css, '#address1_city').send_keys('Ocean', :space, 'sie', :left, 'd')
expect(@session.find(:css, '#address1_city').value).to eq 'Ocean side'
end

it "should allow for multiple simultaneous keys" do
pending "selenium-webdriver/geckodriver doesn't support complex sets of characters" if marionette?(@session)
@session.visit('/form')
@session.find(:css, '#address1_city').send_keys([:shift, 'o'], 'ceanside')
expect(@session.find(:css, '#address1_city').value).to eq 'Oceanside'
end

it "should generate key events", requires: [:send_keys, :js] do
pending "selenium-webdriver/geckodriver doesn't support complex sets of characters" if marionette?(@session)
@session.visit('/with_js')
@session.find(:css, '#with-key-events').send_keys([:shift,'t'], [:shift,'w'])
expect(@session.find(:css, '#key-events-output')).to have_text('keydown:16 keydown:84 keydown:16 keydown:87')
Expand Down
4 changes: 4 additions & 0 deletions lib/capybara/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def extract_results(session)
expect(session).to have_xpath("//pre[@id='results']")
YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip
end

def marionette?(session)
session.driver.respond_to?(:marionette?) && session.driver.marionette?
end
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/shared_selenium_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@

context "#fill_in with { clear: Array } fill_options" do
it 'should pass the array through to the element' do
pending "selenium-webdriver/geckodriver doesn't support complex sets of characters" if @session.driver.marionette?
#this is mainly for use with [[:ctrl, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
@session.visit('/form')
@session.fill_in('form_first_name', with: 'Harry',
Expand Down

0 comments on commit e77471e

Please sign in to comment.