Ensure the attribute exists before returning its value
This commit is contained in:
parent
7ace6dce54
commit
3c8ad255ad
|
@ -12,7 +12,11 @@ module Capybara::Webkit
|
||||||
if name == 'checked' || name == 'disabled' || name == 'multiple'
|
if name == 'checked' || name == 'disabled' || name == 'multiple'
|
||||||
value == 'true'
|
value == 'true'
|
||||||
else
|
else
|
||||||
|
if invoke("hasAttribute", name) == 'true'
|
||||||
value
|
value
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -773,7 +773,7 @@ describe Capybara::Webkit::Driver do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not modify the selected attribute of a new selection" do
|
it "does not modify the selected attribute of a new selection" do
|
||||||
monkey_option['selected'].should be_empty
|
monkey_option['selected'].should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the old value when a reset button is clicked" do
|
it "returns the old value when a reset button is clicked" do
|
||||||
|
|
|
@ -64,6 +64,10 @@ Capybara = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
hasAttribute: function(index, name) {
|
||||||
|
return this.nodes[index].hasAttribute(name);
|
||||||
|
},
|
||||||
|
|
||||||
path: function(index) {
|
path: function(index) {
|
||||||
return "/" + this.getXPathNode(this.nodes[index]).join("/");
|
return "/" + this.getXPathNode(this.nodes[index]).join("/");
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue