mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merge pull request #948 from benlovell/add_element_disabled
Add element disabled?
This commit is contained in:
commit
f17b37bdba
8 changed files with 62 additions and 2 deletions
|
@ -57,6 +57,10 @@ module Capybara
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disabled?
|
||||||
|
raise NotImplementedError
|
||||||
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
raise NotSupportedByDriverError
|
raise NotSupportedByDriverError
|
||||||
end
|
end
|
||||||
|
|
|
@ -142,6 +142,16 @@ module Capybara
|
||||||
synchronize { base.selected? }
|
synchronize { base.selected? }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
#
|
||||||
|
# Whether or not the element is disabled.
|
||||||
|
#
|
||||||
|
# @return [Boolean] Whether the element is disabled
|
||||||
|
#
|
||||||
|
def disabled?
|
||||||
|
synchronize { base.disabled? }
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
# An XPath expression describing where on the page the element can be found
|
# An XPath expression describing where on the page the element can be found
|
||||||
|
|
|
@ -108,6 +108,15 @@ module Capybara
|
||||||
native[:checked]
|
native[:checked]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
#
|
||||||
|
# Whether or not the element is disabled.
|
||||||
|
#
|
||||||
|
# @return [Boolean] Whether the element is disabled
|
||||||
|
def disabled?
|
||||||
|
native[:disabled]
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
# Whether or not the element is selected.
|
# Whether or not the element is selected.
|
||||||
|
|
|
@ -68,6 +68,10 @@ class Capybara::RackTest::Node < Capybara::Driver::Node
|
||||||
string_node.selected?
|
string_node.selected?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disabled?
|
||||||
|
string_node.disabled?
|
||||||
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
native.path
|
native.path
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,6 +70,10 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
||||||
selected and selected != "false"
|
selected and selected != "false"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disabled?
|
||||||
|
!native.enabled?
|
||||||
|
end
|
||||||
|
|
||||||
alias :checked? :selected?
|
alias :checked? :selected?
|
||||||
|
|
||||||
def find(locator)
|
def find(locator)
|
||||||
|
|
|
@ -81,6 +81,14 @@ Capybara::SpecHelper.spec "node" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#disabled?" do
|
||||||
|
it "should extract disabled node" do
|
||||||
|
@session.visit('/form')
|
||||||
|
@session.find('//input[@id="customer_name"]').should be_disabled
|
||||||
|
@session.find('//input[@id="customer_email"]').should_not be_disabled
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#visible?" do
|
describe "#visible?" do
|
||||||
it "should extract node visibility" do
|
it "should extract node visibility" do
|
||||||
@session.first('//a').should be_visible
|
@session.first('//a').should be_visible
|
||||||
|
|
|
@ -9,8 +9,19 @@
|
||||||
<option>Mr</option>
|
<option>Mr</option>
|
||||||
<option>Miss</option>
|
<option>Miss</option>
|
||||||
</select>
|
</select>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="customer_name">Customer Name
|
||||||
|
<input type="text" name="form[customer_name]" value="Blah" id="customer_name" disabled="disabled"/>
|
||||||
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="customer_email">Customer Email
|
||||||
|
<input type="text" name="form[customer_email]" value="ben@ben.com" id="customer_email"/>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label for="form_other_title">Other title</label>
|
<label for="form_other_title">Other title</label>
|
||||||
|
|
|
@ -10,6 +10,11 @@ describe Capybara do
|
||||||
<p>Yes it is</p>
|
<p>Yes it is</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<input type="text" name="bleh" disabled="disabled"/>
|
||||||
|
<input type="text" name="meh"/>
|
||||||
|
</form>
|
||||||
|
|
||||||
<div id="footer" style="display: none">
|
<div id="footer" style="display: none">
|
||||||
<p>c2010</p>
|
<p>c2010</p>
|
||||||
<p>Jonas Nicklas</p>
|
<p>Jonas Nicklas</p>
|
||||||
|
@ -77,13 +82,18 @@ describe Capybara do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows finding elements and extracting the path" do
|
it "allows finding elements and extracting the path" do
|
||||||
string.find('//input').value.should == 'bar'
|
string.find('//div/input').value.should == 'bar'
|
||||||
string.find('//select').value.should == 'Capybara'
|
string.find('//select').value.should == 'Capybara'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows finding elements and checking if they are visible" do
|
it "allows finding elements and checking if they are visible" do
|
||||||
string.find('//h1').should be_visible
|
string.find('//h1').should be_visible
|
||||||
string.find('//input').should_not be_visible
|
string.find('//div/input').should_not be_visible
|
||||||
|
end
|
||||||
|
|
||||||
|
it "allows finding elements and checking if they are disabled" do
|
||||||
|
string.find('//form/input[@name="bleh"]').should be_disabled
|
||||||
|
string.find('//form/input[@name="meh"]').should_not be_disabled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue