Skip to content
This repository

Check for element found under 'Get Text' and 'Element Should Contain' keywords #127

Merged
merged 1 commit into from over 1 year ago

1 participant

Ed Manlove
Ed Manlove
Collaborator

Require 'Get Text' and 'Element Should Contain' keywords to find elements as indicated by locator. Otherwise these keywords should report a ValueError indicating element could not be found.

Ed Manlove Require 'Get Text' and 'Element Should Contain' keywords to find elem…
…ents as indicated by locator. Otherwise these keywords should report a ValueError indicating element could not be found.
9fe2bd2
Ed Manlove emanlove merged commit b8d7b77 into from October 02, 2012
Ed Manlove emanlove closed this October 02, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 02, 2012
Ed Manlove Require 'Get Text' and 'Element Should Contain' keywords to find elem…
…ents as indicated by locator. Otherwise these keywords should report a ValueError indicating element could not be found.
9fe2bd2
This page is out of date. Refresh to see the latest.
2  src/Selenium2Library/keywords/_element.py
@@ -523,7 +523,7 @@ def _frame_contains(self, locator, text):
523 523
         return found
524 524
 
525 525
     def _get_text(self, locator):
526  
-        element = self._element_find(locator, True, False)
  526
+        element = self._element_find(locator, True, True)
527 527
         if element is not None:
528 528
             return element.text
529 529
         return None
2  test/acceptance/keywords/content_assertions.txt
@@ -81,6 +81,7 @@ Page Should Not Contain Element With Disabling Source Logging
81 81
 Element Should Contain
82 82
     Element Should Contain  some_id  This text is inside an identified element
83 83
     Run Keyword And Expect Error  Element 'some_id' should have contained text 'non existing text' but its text was 'This text is inside an identified element'.  Element Should Contain  some_id  non existing text
  84
+    Run Keyword And Expect Error  ValueError: Element locator 'missing_id' did not match any elements.  Element Should Contain  missing_id  This should report missing element.
84 85
 
85 86
 Element Text Should Be
86 87
     Element Text Should Be  some_id  This text is inside an identified element
@@ -89,6 +90,7 @@ Element Text Should Be
89 90
 Get Text
90 91
     ${str} =  Get Text  some_id
91 92
     Should Match  ${str}  This text is inside an identified element
  93
+    Run Keyword And Expect Error  ValueError: Element locator 'missing_id' did not match any elements.  Get Text  missing_id
92 94
 
93 95
 Element Should Be Visible
94 96
     [Setup]  Go To Page "visibility.html"
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.