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

Fix find_by_text to deal with " #420

Merged
merged 2 commits into from
Sep 29, 2015
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion splinter/driver/djangoclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def find_by_value(self, value):
return self.find_by_xpath('//*[@value="%s"]' % value, original_find="value", original_selector=value)

def find_by_text(self, text):
return self.find_by_xpath('//*[text()="%s"]' % text, original_find="text", original_selector=text)
return self.find_by_xpath('//*[text()="%s"]' % text.replace('"', '\"'), original_find="text", original_selector=text)

def find_by_id(self, id_value):
return self.find_by_xpath(
Expand Down
5 changes: 5 additions & 0 deletions tests/find_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def test_finding_by_text(self):
element = self.browser.find_by_text('Complex')
self.assertEqual(element.value, 'Complex')

def test_finding_by_text_quotation(self):
"should find elements by text"
element = self.browser.find_by_text('Quotation " marks')
self.assertEqual(element.value, 'Quotation " marks')

def test_finding_by_id(self):
"should find elements by id"
value = self.browser.find_by_id("firstheader").value
Expand Down
1 change: 1 addition & 0 deletions tests/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ <h1 id="firstheader">Example Last Header</h1>
<i class="fa fa-fw fa-user"></i>
&nbsp;
<span>Complex</span>
<span>Quotation " marks</span>
<span style="display: inline;" class="env-DEV">Link</span>
</a>
<a href="http://localhost:5000/foo">A wordier (and last) link to FOO</a>
Expand Down