Skip to content

Commit 9fe2bd2

Browse files
committed
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.
1 parent ef04583 commit 9fe2bd2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Selenium2Library/keywords/_element.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def _frame_contains(self, locator, text):
523523
return found
524524

525525
def _get_text(self, locator):
526-
element = self._element_find(locator, True, False)
526+
element = self._element_find(locator, True, True)
527527
if element is not None:
528528
return element.text
529529
return None

test/acceptance/keywords/content_assertions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Page Should Not Contain Element With Disabling Source Logging
8181
Element Should Contain
8282
Element Should Contain some_id This text is inside an identified element
8383
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.
8485

8586
Element Text Should Be
8687
Element Text Should Be some_id This text is inside an identified element
@@ -89,6 +90,7 @@ Element Text Should Be
8990
Get Text
9091
${str} = Get Text some_id
9192
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
9294

9395
Element Should Be Visible
9496
[Setup] Go To Page "visibility.html"

0 commit comments

Comments
 (0)