forked from teamcapybara/capybara
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request teamcapybara#1322 from jnicklas/modal
API for operation with modal dialogs
- Loading branch information
Showing
14 changed files
with
464 additions
and
7 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
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
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
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
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
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
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,58 @@ | ||
Capybara::SpecHelper.spec '#accept_alert', :requires => [:modals] do | ||
before do | ||
@session.visit('/with_js') | ||
end | ||
|
||
it "should accept the alert" do | ||
@session.accept_alert do | ||
@session.click_link('Open alert') | ||
end | ||
expect(@session).to have_xpath("//a[@id='open-alert' and @opened='true']") | ||
end | ||
|
||
it "should accept the alert if the text matches" do | ||
@session.accept_alert 'Alert opened' do | ||
@session.click_link('Open alert') | ||
end | ||
expect(@session).to have_xpath("//a[@id='open-alert' and @opened='true']") | ||
end | ||
|
||
it "should not accept the alert if the text doesnt match" do | ||
expect do | ||
@session.accept_alert 'Incorrect Text' do | ||
@session.click_link('Open alert') | ||
end | ||
end.to raise_error(Capybara::ModalNotFound) | ||
# @session.accept_alert {} # clear the alert so browser continues to function | ||
end | ||
|
||
it "should return the message presented" do | ||
message = @session.accept_alert do | ||
@session.click_link('Open alert') | ||
end | ||
expect(message).to eq('Alert opened') | ||
end | ||
|
||
context "with an asynchronous alert" do | ||
it "should accept the alert" do | ||
@session.accept_alert do | ||
@session.click_link('Open delayed alert') | ||
end | ||
expect(@session).to have_xpath("//a[@id='open-delayed-alert' and @opened='true']") | ||
end | ||
|
||
it "should return the message presented" do | ||
message = @session.accept_alert do | ||
@session.click_link('Open delayed alert') | ||
end | ||
expect(message).to eq('Delayed alert opened') | ||
end | ||
|
||
it "should allow to adjust the delay" do | ||
@session.accept_alert wait: 4 do | ||
@session.click_link('Open slow alert') | ||
end | ||
expect(@session).to have_xpath("//a[@id='open-slow-alert' and @opened='true']") | ||
end | ||
end | ||
end |
Oops, something went wrong.