Implemented Node#click
This commit is contained in:
parent
b9ecd40191
commit
c9d1bffe51
|
@ -25,7 +25,7 @@ class Capybara::Driver::Webkit
|
||||||
end
|
end
|
||||||
|
|
||||||
def click
|
def click
|
||||||
raise NotImplementedError
|
invoke "click"
|
||||||
end
|
end
|
||||||
|
|
||||||
def drag_to(element)
|
def drag_to(element)
|
||||||
|
|
|
@ -9,6 +9,7 @@ describe Capybara::Driver::Webkit do
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.write("<p id='greeting'>he" + "llo</p>");
|
document.write("<p id='greeting'>he" + "llo</p>");
|
||||||
</script>
|
</script>
|
||||||
|
<a href="/next">Next</a>
|
||||||
</body></html>
|
</body></html>
|
||||||
HTML
|
HTML
|
||||||
[200,
|
[200,
|
||||||
|
@ -58,6 +59,7 @@ describe Capybara::Driver::Webkit do
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.write("<p id='greeting'>he" + "llo</p>");
|
document.write("<p id='greeting'>he" + "llo</p>");
|
||||||
</script><p id="greeting">hello</p>
|
</script><p id="greeting">hello</p>
|
||||||
|
<a href="/next">Next</a>
|
||||||
|
|
||||||
</body></html>}
|
</body></html>}
|
||||||
end
|
end
|
||||||
|
@ -126,6 +128,11 @@ describe Capybara::Driver::Webkit do
|
||||||
to raise_error(Capybara::Driver::Webkit::WebkitError)
|
to raise_error(Capybara::Driver::Webkit::WebkitError)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "clicks an element" do
|
||||||
|
subject.find("//a").first.click
|
||||||
|
subject.current_url =~ %r{/next$}
|
||||||
|
end
|
||||||
|
|
||||||
it "returns a node's tag name" do
|
it "returns a node's tag name" do
|
||||||
subject.find("//p").first.tag_name.should == "p"
|
subject.find("//p").first.tag_name.should == "p"
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,12 @@ Capybara = {
|
||||||
|
|
||||||
tagName: function(index) {
|
tagName: function(index) {
|
||||||
return this.nodes[index].tagName.toLowerCase();
|
return this.nodes[index].tagName.toLowerCase();
|
||||||
|
},
|
||||||
|
|
||||||
|
click: function (index) {
|
||||||
|
var clickEvent = document.createEvent('MouseEvents');
|
||||||
|
clickEvent.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||||
|
this.nodes[index].dispatchEvent(clickEvent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue