Skip to content

Commit

Permalink
rb - removed unnecessary guards on specs
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Nov 29, 2015
1 parent 2917565 commit 3df463f
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 142 deletions.
7 changes: 3 additions & 4 deletions rb/spec/integration/selenium/webdriver/app_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

require_relative 'spec_helper'


module Selenium::WebDriver::DriverExtensions
describe "HasApplicationCache" do

compliant_on :browser => nil do
compliant_on :browser => nil do
describe "HasApplicationCache" do

it "gets the app cache status" do
expect(driver.application_cache.status).to eq(:uncached)

Expand Down Expand Up @@ -61,6 +61,5 @@ module Selenium::WebDriver::DriverExtensions
end
end
end

end
end
79 changes: 43 additions & 36 deletions rb/spec/integration/selenium/webdriver/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
require_relative 'spec_helper'

describe "Driver" do

it "should get the page title" do
driver.navigate.to url_for("xhtmlTest.html")
expect(driver.title).to eq("XHTML Test Page")
Expand All @@ -30,44 +31,47 @@
expect(driver.page_source).to match(%r[<title>XHTML Test Page</title>]i)
end

not_compliant_on :browser => :safari do
it "should refresh the page" do
driver.navigate.to url_for("javascriptPage.html")
driver.find_element(:id, 'updatediv').click
expect(driver.find_element(:id, 'dynamo').text).to eq("Fish and chips!")
driver.navigate.refresh
expect(driver.find_element(:id, 'dynamo').text).to eq("What's for dinner?")
end
it "should refresh the page" do
driver.navigate.to url_for("javascriptPage.html")
sleep 1 # javascript takes too long to load
driver.find_element(:id, 'updatediv').click
expect(driver.find_element(:id, 'dynamo').text).to eq("Fish and chips!")
driver.navigate.refresh
expect(driver.find_element(:id, 'dynamo').text).to eq("What's for dinner?")
end

not_compliant_on :browser => [ :iphone, :safari] do
it "should save a screenshot" do
driver.navigate.to url_for("xhtmlTest.html")
path = "screenshot_tmp.png"

begin
driver.save_screenshot path
expect(File.exist?(path)).to be true # sic
expect(File.size(path)).to be > 0
ensure
File.delete(path) if File.exist?(path)
not_compliant_on :browser => :iphone do
context "screenshots" do

it "should save" do
driver.navigate.to url_for("xhtmlTest.html")
path = "screenshot_tmp.png"

begin
driver.save_screenshot path
expect(File.exist?(path)).to be true # sic
expect(File.size(path)).to be > 0
ensure
File.delete(path) if File.exist?(path)
end
end
end

it "should return a screenshot in the specified format" do
driver.navigate.to url_for("xhtmlTest.html")
it "should return in the specified format" do
driver.navigate.to url_for("xhtmlTest.html")

ss = driver.screenshot_as(:png)
expect(ss).to be_kind_of(String)
expect(ss.size).to be > 0
end
ss = driver.screenshot_as(:png)
expect(ss).to be_kind_of(String)
expect(ss.size).to be > 0
end

it "raises an error when given an unknown format" do
expect { driver.screenshot_as(:jpeg) }.to raise_error(WebDriver::Error::UnsupportedOperationError)
it "raises an error when given an unknown format" do
expect { driver.screenshot_as(:jpeg) }.to raise_error(WebDriver::Error::UnsupportedOperationError)
end
end
end

describe "one element" do

it "should find by id" do
driver.navigate.to url_for("xhtmlTest.html")
element = driver.find_element(:id, "id1")
Expand Down Expand Up @@ -109,7 +113,7 @@
driver.navigate.to url_for("nestedElements.html")

element = driver.find_element(:name, "form2")
child = element.find_element(:name, "selectomatic")
child = element.find_element(:name, "selectomatic")

expect(child.attribute("id")).to eq("2")
end
Expand All @@ -118,7 +122,7 @@
driver.navigate.to url_for("nestedElements.html")

element = driver.find_element(:name, "form2")
child = element.find_element(:tag_name, "select")
child = element.find_element(:tag_name, "select")

expect(child.attribute("id")).to eq("2")
end
Expand All @@ -142,6 +146,7 @@
end

describe "many elements" do

it "should find by class name" do
driver.navigate.to url_for("xhtmlTest.html")
expect(driver.find_elements(:class, "nameC").size).to eq(2)
Expand All @@ -161,6 +166,7 @@
end

describe "execute script" do

it "should return strings" do
driver.navigate.to url_for("xhtmlTest.html")
expect(driver.execute_script("return document.title;")).to eq("XHTML Test Page")
Expand Down Expand Up @@ -212,7 +218,7 @@
end

# Marionette BUG - Not finding local javascript for execution
not_compliant_on({:driver => :marionette}, {:browser => :marionette}) do
not_compliant_on :browser => :marionette do
it "should be able to call functions on the page" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("displayMessage('I like cheese');")
Expand Down Expand Up @@ -257,12 +263,13 @@
end
end

not_compliant_on :browser => [:iphone, :android, :phantomjs] do
not_compliant_on :browser => [:iphone, :android] do
describe "execute async script" do
before {

before do
driver.manage.timeouts.script_timeout = 0
driver.navigate.to url_for("ajaxy_page.html")
}
end

it "should be able to return arrays of primitives from async scripts" do
result = driver.execute_async_script "arguments[arguments.length - 1]([null, 123, 'abc', true, false]);"
Expand All @@ -275,7 +282,8 @@
end

# Edge BUG - https://connect.microsoft.com/IE/feedback/details/1849991/
not_compliant_on({:browser => :edge}, {:driver => :remote, :browser => :marionette}) do
not_compliant_on({:browser => [:edge, :marionette]},
{:driver => :remote, :browser => :phantomjs}) do
it "times out if the callback is not invoked" do
expect {
# Script is expected to be async and explicitly callback, so this should timeout.
Expand All @@ -285,5 +293,4 @@
end
end
end

end
40 changes: 13 additions & 27 deletions rb/spec/integration/selenium/webdriver/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@
not_compliant_on :browser => :marionette do
it "should submit" do
driver.navigate.to url_for("formPage.html")
wait(5).until {driver.find_elements(:id, "submitButton").size > 0}
wait_for_element(:id => "submitButton")
driver.find_element(:id, "submitButton").submit
end
end

it "should send string keys" do
driver.navigate.to url_for("formPage.html")
wait_for_element(:id => "working")
driver.find_element(:id, "working").send_keys("foo", "bar")
end

not_compliant_on :browser => [:android, :iphone, :safari] do
not_compliant_on :browser => [:android, :iphone] do
it "should send key presses" do
driver.navigate.to url_for("javascriptPage.html")
key_reporter = driver.find_element(:id, 'keyReporter')
Expand All @@ -59,12 +60,8 @@
end
end

# FIXME - Find alternate implementation for File Uploads
# TODO - Figure out if/how this works on Firefox/Chrome without Remote server
# PhantomJS on windows issue: https://github.com/ariya/phantomjs/issues/10993
not_compliant_on({:browser => [:android, :iphone, :safari, :edge, :marionette]},
{:browser => :phantomjs, :platform => [:windows, :linux]},
{:driver => :marionette}) do
not_compliant_on :browser => [:android, :iphone, :safari, :edge, :marionette, :phantomjs] do
it "should handle file uploads" do
driver.navigate.to url_for("formPage.html")

Expand Down Expand Up @@ -93,15 +90,6 @@
end
end

# Per W3C spec this should return Invalid Argument not Unknown Error, but there is no comparable error code
compliant_on :browser => :edge do
it "should return nil for non-existent attributes" do
driver.navigate.to url_for("formPage.html")
element = driver.find_element(:id, "withText")
expect {element.attribute("nonexistent")}.to raise_error(Selenium::WebDriver::Error::UnknownError)
end
end

it "should clear" do
driver.navigate.to url_for("formPage.html")
driver.find_element(:id, "withText").clear
Expand Down Expand Up @@ -167,7 +155,7 @@
expect(size.height).to be > 0
end

compliant_on :driver => [:ie, :chrome, :edge] do # Firefox w/native events: issue 1771
not_compliant_on :browser => [:safari, :marionette] do
it "should drag and drop" do
driver.navigate.to url_for("dragAndDropTest.html")

Expand All @@ -182,7 +170,7 @@
end
end

not_compliant_on :browser => [:android] do # android returns 'green'
not_compliant_on :browser => :android do # android returns 'green'
it "should get css property" do
driver.navigate.to url_for("javascriptPage.html")
element = driver.find_element(:id, "green-parent")
Expand All @@ -205,17 +193,15 @@
expect(body).to eql(xbody)
end

not_compliant_on :browser => :phantomjs do
it "should know when two elements are not equal" do
driver.navigate.to url_for("simpleTest.html")
it "should know when two elements are not equal" do
driver.navigate.to url_for("simpleTest.html")

elements = driver.find_elements(:tag_name, 'p')
p1 = elements.fetch(0)
p2 = elements.fetch(1)
elements = driver.find_elements(:tag_name, 'p')
p1 = elements.fetch(0)
p2 = elements.fetch(1)

expect(p1).not_to eq(p2)
expect(p1).not_to eql(p2)
end
expect(p1).not_to eq(p2)
expect(p1).not_to eql(p2)
end

it "should return the same #hash for equal elements when found by Driver#find_element" do
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}.to raise_error(WebDriver::Error::NoSuchElementError)
end

compliant_on({:driver => :firefox}, {:driver => :remote, :browser => :firefox}) do
compliant_on :browser => :firefox do
it "should show stack trace information" do
driver.navigate.to url_for("xhtmlTest.html")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ module Selenium
module WebDriver

describe Firefox do
before(:each) do
before do
@opt = GlobalTestEnv.remote_server? ? {:url => GlobalTestEnv.remote_server.webdriver_url} : {}
end

context "when designated firefox binary includes Marionette" do
before(:each) do
before do
unless ENV['MARIONETTE_PATH']
pending "Set ENV['MARIONETTE_PATH'] to test Marionette enabled Firefox installations"
end
Expand Down
4 changes: 2 additions & 2 deletions rb/spec/integration/selenium/webdriver/keyboard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ module Selenium
module WebDriver

# Marionette BUG - Interactions Not Supported
not_compliant_on({:browser => [:chrome, :android, :iphone, :safari, :marionette]},
{:driver => :marionette}) do
not_compliant_on :browser => [:android, :iphone, :safari, :marionette] do
describe Keyboard do

it "sends keys to the active element" do
driver.navigate.to url_for("bodyTypingTest.html")

Expand Down
8 changes: 3 additions & 5 deletions rb/spec/integration/selenium/webdriver/mouse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
module Selenium
module WebDriver

describe Mouse do
# Marionette BUG - Interactions Not Supported
not_compliant_on :browser => [:android, :iphone, :safari, :marionette] do
describe Mouse do

# Marionette BUG - Interactions Not Supported
not_compliant_on({:browser => [:android, :iphone, :safari, :marionette]},
{:driver => :marionette}) do
it "clicks an element" do
driver.navigate.to url_for("formPage.html")
driver.mouse.click driver.find_element(:id, "imageButton")
Expand Down Expand Up @@ -76,7 +75,6 @@ module WebDriver
end
end
end

end
end
end
20 changes: 9 additions & 11 deletions rb/spec/integration/selenium/webdriver/navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
require_relative 'spec_helper'

describe "Navigation" do
let(:wait) { Selenium::WebDriver::Wait.new :timeout => 10 }

not_compliant_on :browser => :safari do
it "should navigate back and forward" do
Expand All @@ -47,19 +46,18 @@
expect(driver.current_url).to include(result_url)
expect(driver.title).to eq(result_title)
end
end

it "should refresh the page" do
changed_title = "Changed"
it "should refresh the page" do
changed_title = "Changed"

driver.navigate.to url_for("javascriptPage.html")
driver.find_element(:link_text, "Change the page title!").click
expect(driver.title).to eq(changed_title)
driver.navigate.to url_for("javascriptPage.html")
driver.find_element(:link_text, "Change the page title!").click
expect(driver.title).to eq(changed_title)

driver.navigate.refresh
wait.until { driver.title != changed_title }
driver.navigate.refresh
wait.until { driver.title != changed_title }

expect(driver.title).to eq("Testing Javascript")
end
expect(driver.title).to eq("Testing Javascript")
end
end

Loading

0 comments on commit 3df463f

Please sign in to comment.