Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding method click_link_by_id #498

Merged
merged 1 commit into from Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/elements-in-the-page.rst
Expand Up @@ -67,6 +67,14 @@ or

browser.click_link_by_partial_text('part of link text')

or

.. highlight:: python

::

browser.click_link_by_id('link_id')


Clicking buttons
----------------
Expand Down
6 changes: 6 additions & 0 deletions splinter/driver/__init__.py
Expand Up @@ -330,6 +330,12 @@ def click_link_by_partial_text(self, partial_text):
"""
return self.find_link_by_partial_text(partial_text).first.click()

def click_link_by_id(self, id):
"""
Clicks in a link by id.
"""
return self.find_by_id(id).first.click()

def quit(self):
"""
Quits the browser, closing its windows (if it has one).
Expand Down
4 changes: 4 additions & 0 deletions tests/click_elements.py
Expand Up @@ -34,3 +34,7 @@ def test_click_link_by_text(self):
def test_click_link_by_partial_text(self):
self.browser.click_link_by_partial_text("wordier")
self.assertIn("BAR!", self.browser.html)

def test_click_link_by_id(self):
self.browser.click_link_by_id('foo')
self.assertIn("BAR!", self.browser.html)
2 changes: 1 addition & 1 deletion tests/static/index.html
Expand Up @@ -129,7 +129,7 @@ <h1 id="firstheader">Example Last Header</h1>
<a class="show-invisible-element" href="#">Show invisible element</a>
<div id="simple_text">my test text</div>
<div id="text_with_html">another <b>b</b>it of text</div>
<a href="http://localhost:5000/foo">FOO</a>
<a href="http://localhost:5000/foo" id="foo">FOO</a>
<a href="http://localhost:5000/foo">
<i class="fa fa-fw fa-user"></i>
&nbsp;
Expand Down