-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use one browser instance for all specs + move specs to top level.
Launching a new browser for each spec is cheap with HtmlUnit, but doesn't make any sense for implementations on real browsers.
- Loading branch information
Showing
175 changed files
with
6,743 additions
and
7,227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
describe "Area" do | ||
|
||
before :each do | ||
browser.goto(WatirSpec.files + "/images.html") | ||
end | ||
|
||
# Exists method | ||
describe "#exist?" do | ||
it "returns true if the area exists" do | ||
browser.area(:id, "NCE").should exist | ||
browser.area(:id, /NCE/).should exist | ||
browser.area(:name, "NCE").should exist | ||
browser.area(:name, /NCE/).should exist | ||
browser.area(:title, "Tables").should exist | ||
browser.area(:title, /Tables/).should exist | ||
browser.area(:url, "tables.html").should exist | ||
browser.area(:url, /tables/).should exist | ||
browser.area(:index, 1).should exist | ||
browser.area(:xpath, "//area[@id='NCE']").should exist | ||
end | ||
|
||
it "returns true if the element exists (default how = :id)" do | ||
browser.area("NCE").should exist | ||
end | ||
|
||
it "returns false if the area doesn't exist" do | ||
browser.area(:id, "no_such_id").should_not exist | ||
browser.area(:id, /no_such_id/).should_not exist | ||
browser.area(:name, "no_such_id").should_not exist | ||
browser.area(:name, /no_such_id/).should_not exist | ||
browser.area(:title, "no_such_title").should_not exist | ||
browser.area(:title, /no_such_title/).should_not exist | ||
browser.area(:url, "no_such_href").should_not exist | ||
browser.area(:url, /no_such_href/).should_not exist | ||
browser.area(:index, 1337).should_not exist | ||
browser.area(:xpath, "//area[@id='no_such_id']").should_not exist | ||
end | ||
|
||
it "raises TypeError when 'what' argument is invalid" do | ||
lambda { browser.area(:id, 3.14).exists? }.should raise_error(TypeError) | ||
end | ||
|
||
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do | ||
lambda { browser.area(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException) | ||
end | ||
end | ||
|
||
# Attribute methods | ||
describe "#id" do | ||
it "returns the id attribute" do | ||
browser.area(:index, 1).id.should == "NCE" | ||
end | ||
|
||
it "returns an empty string if the element exists and the attribute doesn't" do | ||
browser.area(:index, 3).id.should == '' | ||
end | ||
|
||
it "raises UnknownObjectException if the area doesn't exist" do | ||
lambda { browser.area(:id, "no_such_id").id }.should raise_error(UnknownObjectException) | ||
lambda { browser.area(:index, 1337).id }.should raise_error(UnknownObjectException) | ||
end | ||
|
||
end | ||
|
||
describe "#name" do | ||
it "returns the name attribute" do | ||
browser.area(:index, 1).name.should == "NCE" | ||
end | ||
|
||
it "returns an empty string if the element exists and the attribute doesn't" do | ||
browser.area(:index, 3).name.should == '' | ||
end | ||
|
||
it "raises UnknownObjectException if the area doesn't exist" do | ||
lambda { browser.area(:id, "no_such_id").name }.should raise_error(UnknownObjectException) | ||
lambda { browser.area(:index, 1337).name }.should raise_error(UnknownObjectException) | ||
end | ||
end | ||
|
||
describe "#respond_to?" do | ||
it "returns true for all attribute methods" do | ||
browser.area(:index, 1).should respond_to(:id) | ||
browser.area(:index, 1).should respond_to(:name) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
describe "Areas" do | ||
|
||
before :each do | ||
browser.goto(WatirSpec.files + "/images.html") | ||
end | ||
|
||
describe "#length" do | ||
it "returns the number of areas" do | ||
browser.areas.length.should == 3 | ||
end | ||
end | ||
|
||
describe "#[]" do | ||
it "returns the area at the given index" do | ||
browser.areas[1].id.should == "NCE" | ||
end | ||
end | ||
|
||
describe "#each" do | ||
it "iterates through areas correctly" do | ||
browser.areas.each_with_index do |a, index| | ||
a.name.should == browser.area(:index, index+1).name | ||
a.id.should == browser.area(:index, index+1).id | ||
a.value.should == browser.area(:index, index+1).value | ||
end | ||
end | ||
end | ||
|
||
|
||
|
||
end | ||
|
Oops, something went wrong.