Skip to content

Commit

Permalink
rb: update specs for Microsoft Edge
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jul 31, 2015
1 parent 057e2bc commit d4a50f1
Show file tree
Hide file tree
Showing 10 changed files with 353 additions and 265 deletions.
218 changes: 121 additions & 97 deletions rb/spec/integration/selenium/webdriver/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@
driver.title.should == "XHTML Test Page"
end

it "should get the page source" do
driver.navigate.to url_for("xhtmlTest.html")
driver.page_source.should match(%r[<title>XHTML Test Page</title>]i)
# Edge does not yet support session/:sessionId/source http://dev.modern.ie/platform/status/webdriver/details/
not_compliant_on :browser => :edge do
it "should get the page source" do
driver.navigate.to url_for("xhtmlTest.html")
driver.page_source.should match(%r[<title>XHTML Test Page</title>]i)
end
end


not_compliant_on :browser => :safari do
it "should refresh the page" do
driver.navigate.to url_for("javascriptPage.html")
driver.find_element(:link_text, 'Update a div').click
driver.find_element(:id, 'updatediv').click
driver.find_element(:id, 'dynamo').text.should == "Fish and chips!"
driver.navigate.refresh
driver.find_element(:id, 'dynamo').text.should == "What's for dinner?"
Expand Down Expand Up @@ -91,9 +93,12 @@
driver.find_element(:link, "Foo").text.should == "Foo"
end

it "should find by xpath" do
driver.navigate.to url_for("xhtmlTest.html")
driver.find_element(:xpath, "//h1").text.should == "XHTML Might Be The Future"
# Edge does not yet support xpath
not_compliant_on :browser => :edge do
it "should find by xpath" do
driver.navigate.to url_for("xhtmlTest.html")
driver.find_element(:xpath, "//h1").text.should == "XHTML Might Be The Future"
end
end

it "should find by css selector" do
Expand All @@ -106,22 +111,30 @@
driver.find_element(:tag_name, 'div').attribute("class").should == "navigation"
end

it "should find child element" do
driver.navigate.to url_for("nestedElements.html")
# Edge does not yet support session/:sessionId/element/:id/element
# http://dev.modern.ie/platform/status/webdriver/details/
not_compliant_on :browser => :edge do
it "should find child element" do
driver.navigate.to url_for("nestedElements.html")

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

child.attribute("id").should == "2"
child.attribute("id").should == "2"
end
end

it "should find child element by tag name" do
driver.navigate.to url_for("nestedElements.html")
# Edge does not yet support session/:sessionId/element/:id/element
# http://dev.modern.ie/platform/status/webdriver/details/
not_compliant_on :browser => :edge do
it "should find child element by tag name" do
driver.navigate.to url_for("nestedElements.html")

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

child.attribute("id").should == "2"
child.attribute("id").should == "2"
end
end

it "should raise on nonexistant element" do
Expand All @@ -134,11 +147,14 @@
driver.find_element(:class => "header").text.should == "XHTML Might Be The Future"
end

it "should find elements with the shortcut syntax" do
driver.navigate.to url_for("xhtmlTest.html")
# Edge does not yet support xpath
not_compliant_on :browser => :edge do
it "should find elements with the shortcut syntax" do
driver.navigate.to url_for("xhtmlTest.html")

driver[:id1].should be_kind_of(WebDriver::Element)
driver[:xpath => "//h1"].should be_kind_of(WebDriver::Element)
driver[:id1].should be_kind_of(WebDriver::Element)
driver[:xpath => "//h1"].should be_kind_of(WebDriver::Element)
end
end
end

Expand All @@ -153,109 +169,117 @@
driver.find_elements(:css, 'p')
end

it "should find children by field name" do
driver.navigate.to url_for("nestedElements.html")
element = driver.find_element(:name, "form2")
children = element.find_elements(:name, "selectomatic")
expect(children.size).to eq(2)
# Edge does not yet support session/:sessionId/element/:id/element
# http://dev.modern.ie/platform/status/webdriver/details/
not_compliant_on :browser => :edge do
it "should find children by field name" do
driver.navigate.to url_for("nestedElements.html")
element = driver.find_element(:name, "form2")
children = element.find_elements(:name, "selectomatic")
expect(children.size).to eq(2)
end
end
end

describe "execute script" do
it "should return strings" do
driver.navigate.to url_for("xhtmlTest.html")
driver.execute_script("return document.title;").should == "XHTML Test Page"
end

it "should return numbers" do
driver.navigate.to url_for("xhtmlTest.html")
driver.execute_script("return document.title.length;").should == "XHTML Test Page".length
end
# Microsoft Edge does not return javascriptEnabled when passed in as desired capabilities
not_compliant_on :browser => :edge do
describe "execute script" do
it "should return strings" do
driver.navigate.to url_for("xhtmlTest.html")
driver.execute_script("return document.title;").should == "XHTML Test Page"
end

it "should return elements" do
driver.navigate.to url_for("xhtmlTest.html")
element = driver.execute_script("return document.getElementById('id1');")
element.should be_kind_of(WebDriver::Element)
element.text.should == "Foo"
end
it "should return numbers" do
driver.navigate.to url_for("xhtmlTest.html")
driver.execute_script("return document.title.length;").should == "XHTML Test Page".length
end

not_compliant_on :browser => [:android] do
it "should unwrap elements in deep objects" do
it "should return elements" do
driver.navigate.to url_for("xhtmlTest.html")
result = driver.execute_script(<<-SCRIPT)
element = driver.execute_script("return document.getElementById('id1');")
element.should be_kind_of(WebDriver::Element)
element.text.should == "Foo"
end

not_compliant_on :browser => [:android] do
it "should unwrap elements in deep objects" do
driver.navigate.to url_for("xhtmlTest.html")
result = driver.execute_script(<<-SCRIPT)
var e1 = document.getElementById('id1');
var body = document.body;
return {
elements: {'body' : body, other: [e1] }
};
SCRIPT
SCRIPT

result.should be_kind_of(Hash)
result['elements']['body'].should be_kind_of(WebDriver::Element)
result['elements']['other'].first.should be_kind_of(WebDriver::Element)
result.should be_kind_of(Hash)
result['elements']['body'].should be_kind_of(WebDriver::Element)
result['elements']['other'].first.should be_kind_of(WebDriver::Element)
end
end
end

it "should return booleans" do
driver.navigate.to url_for("xhtmlTest.html")
driver.execute_script("return true;").should == true
end
it "should return booleans" do
driver.navigate.to url_for("xhtmlTest.html")
driver.execute_script("return true;").should == true
end

it "should raise if the script is bad" do
driver.navigate.to url_for("xhtmlTest.html")
lambda { driver.execute_script("return squiggle();") }.should raise_error
end
it "should raise if the script is bad" do
driver.navigate.to url_for("xhtmlTest.html")
lambda { driver.execute_script("return squiggle();") }.should raise_error
end

it "should return arrays" do
driver.navigate.to url_for("xhtmlTest.html")
driver.execute_script('return ["zero", "one", "two"];').should == %w[zero one two]
end
it "should return arrays" do
driver.navigate.to url_for("xhtmlTest.html")
driver.execute_script('return ["zero", "one", "two"];').should == %w[zero one two]
end

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');")
driver.find_element(:id, "result").text.strip.should == "I like cheese"
end
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');")
driver.find_element(:id, "result").text.strip.should == "I like cheese"
end

it "should be able to pass string arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0] == 'fish' ? 'fish' : 'not fish';", "fish").should == "fish"
end
it "should be able to pass string arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0] == 'fish' ? 'fish' : 'not fish';", "fish").should == "fish"
end

it "should be able to pass boolean arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0] == true;", true).should == true
end
it "should be able to pass boolean arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0] == true;", true).should == true
end

it "should be able to pass numeric arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0] == 1 ? 1 : 0;", 1).should == 1
end
it "should be able to pass numeric arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0] == 1 ? 1 : 0;", 1).should == 1
end

it "should be able to pass null arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0];", nil).should == nil
end
it "should be able to pass null arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0];", nil).should == nil
end

it "should be able to pass array arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0];", [1, '2', 3]).should == [1, '2', 3]
end
it "should be able to pass array arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0];", [1, '2', 3]).should == [1, '2', 3]
end

it "should be able to pass element arguments" do
driver.navigate.to url_for("javascriptPage.html")
button = driver.find_element(:id, "plainButton")
driver.execute_script("arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];", button).should == "plainButton"
end
it "should be able to pass element arguments" do
driver.navigate.to url_for("javascriptPage.html")
button = driver.find_element(:id, "plainButton")
driver.execute_script("arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];", button).should == "plainButton"
end

it "should be able to pass in multiple arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0] + arguments[1];", "one", "two").should == "onetwo"
it "should be able to pass in multiple arguments" do
driver.navigate.to url_for("javascriptPage.html")
driver.execute_script("return arguments[0] + arguments[1];", "one", "two").should == "onetwo"
end
end
end

not_compliant_on :browser => [:iphone, :android, :phantomjs] do
# Microsoft Edge does not return javascriptEnabled when passed in as desired capabilities
not_compliant_on :browser => [:iphone, :android, :phantomjs, :edge] do
describe "execute async script" do
before {
driver.manage.timeouts.script_timeout = 0
Expand Down
Loading

0 comments on commit d4a50f1

Please sign in to comment.