Repository navigation
issue #463 #724
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
issue #463 #724
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,37 @@ def table_cell_should_contain(self, table_locator, row, column, expected, loglev | |
| self.log_source(loglevel) | ||
| raise AssertionError(message) | ||
|
|
||
| def table_cell_should_not_contain(self, table_locator, row, column, value, loglevel='INFO'): | ||
| """ | ||
| Verifies that a certain cell in a table does not contain `expected`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Join lines 77 and 78 as a single line. |
||
|
|
||
| Row and column number start from 1. This keyword passes if the | ||
| specified cell does not contain the given content. If you want | ||
| to test that the cell content does not match exactly, or that | ||
| it e.g. starts with some text, use `Get Table Cell` keyword in | ||
| combination with built-in keywords such as `Should Not Be Equal` | ||
| or `Should Not Start With`. | ||
|
|
||
| To understand how tables are identified, please take a look at | ||
| the `introduction`. | ||
|
|
||
| See `Page Should Contain` for explanation about `loglevel` argument. | ||
| """ | ||
| message = ("Cell in table '%s' in row #%s and column #%s should not have contained text '%s'." | ||
| % (table_locator, row, column, value)) | ||
| cell_not_exist_message = ("Cell in table '%s' in row #%s and column #%s was not found" | ||
| % (table_locator, row, column)) | ||
| try: | ||
| content = self.get_table_cell(table_locator, row, column, loglevel='NONE') | ||
| except AssertionError as err: | ||
| self._info(err) | ||
| self.log_source(loglevel) | ||
| raise AssertionError(cell_not_exist_message) | ||
| self._info("Cell contains %s." % content) | ||
| if value in content: | ||
| self.log_source(loglevel) | ||
| raise AssertionError(message) | ||
|
|
||
| def table_column_should_contain(self, table_locator, col, expected, loglevel='INFO'): | ||
| """Verifies that a specific column contains `expected`. | ||
|
|
||
|
|
@@ -100,6 +131,32 @@ def table_column_should_contain(self, table_locator, col, expected, loglevel='IN | |
| "should have contained text '%s'." | ||
| % (col, table_locator, expected)) | ||
|
|
||
| def table_column_should_not_contain(self, table_locator, col, value, loglevel='INFO'): | ||
| """Verifies that a specific column does not contain `expected`. | ||
|
|
||
| The first leftmost column is column number 1. A negative column | ||
| number can be used to get column counting from the end of the row (end: -1). | ||
| If the table contains cells that span multiple columns, those merged cells | ||
| count as a single column. For example both tests below work, | ||
| if in one row columns A and B are merged with colspan="2", and | ||
| the logical third column contains "C". | ||
|
|
||
| Example: | ||
| | Table Column Should Not Contain | tableId | 3 | C | | ||
| | Table Column Should Not Contain | tableId | 2 | C | | ||
|
|
||
| To understand how tables are identified, please take a look at | ||
| the `introduction`. | ||
|
|
||
| See `Page Should Contain Element` for explanation about | ||
| `loglevel` argument. | ||
| """ | ||
| element = self._table_element_finder.find_by_col(self._current_browser(), table_locator, col, value) | ||
| if element: | ||
| self.log_source(loglevel) | ||
| raise AssertionError("Column #%s in table identified by '%s' should not have contained text '%s'." | ||
| % (col, table_locator, value)) | ||
|
|
||
| def table_footer_should_contain(self, table_locator, expected, loglevel='INFO'): | ||
| """Verifies that the table footer contains `expected`. | ||
|
|
||
|
|
@@ -116,6 +173,22 @@ def table_footer_should_contain(self, table_locator, expected, loglevel='INFO'): | |
| raise AssertionError("Footer in table identified by '%s' should have contained " | ||
| "text '%s'." % (table_locator, expected)) | ||
|
|
||
| def table_footer_should_not_contain(self, table_locator, value, loglevel='INFO'): | ||
| """Verifies that the table footer does not contain `expected`. | ||
|
|
||
| With table footer can be described as any <td>-element that is | ||
| child of a <tfoot>-element. To understand how tables are | ||
| identified, please take a look at the `introduction`. | ||
|
|
||
| See `Page Should Contain Element` for explanation about | ||
| `loglevel` argument. | ||
| """ | ||
| element = self._table_element_finder.find_by_footer(self._current_browser(), table_locator, value) | ||
| if element: | ||
| self.log_source(loglevel) | ||
| raise AssertionError("Footer in table identified by '%s' should not have contained text '%s'." | ||
| % (table_locator, value)) | ||
|
|
||
| def table_header_should_contain(self, table_locator, expected, loglevel='INFO'): | ||
| """Verifies that the table header, i.e. any <th>...</th> element, contains `expected`. | ||
|
|
||
|
|
@@ -131,6 +204,21 @@ def table_header_should_contain(self, table_locator, expected, loglevel='INFO'): | |
| raise AssertionError("Header in table identified by '%s' should have contained " | ||
| "text '%s'." % (table_locator, expected)) | ||
|
|
||
| def table_header_should_not_contain(self, table_locator, value, loglevel='INFO'): | ||
| """Verifies that the table header, i.e. any <th>...</th> element, does not contain `expected`. | ||
|
|
||
| To understand how tables are identified, please take a look at | ||
| the `introduction`. | ||
|
|
||
| See `Page Should Contain Element` for explanation about | ||
| `loglevel` argument. | ||
| """ | ||
| element = self._table_element_finder.find_by_header(self._current_browser(), table_locator, value) | ||
| if element: | ||
| self.log_source(loglevel) | ||
| raise AssertionError("Header in table identified by '%s' should not have contained text '%s'." | ||
| % (table_locator, value)) | ||
|
|
||
| def table_row_should_contain(self, table_locator, row, expected, loglevel='INFO'): | ||
| """Verifies that a specific table row contains `expected`. | ||
|
|
||
|
|
@@ -154,6 +242,29 @@ def table_row_should_contain(self, table_locator, row, expected, loglevel='INFO' | |
| raise AssertionError("Row #%s in table identified by '%s' should have contained " | ||
| "text '%s'." % (row, table_locator, expected)) | ||
|
|
||
| def table_row_should_not_contain(self, table_locator, row, value, loglevel='INFO'): | ||
| """Verifies that a specific table row does not contain `expected`. | ||
|
|
||
| The uppermost row is row number 1. A negative column | ||
| number can be used to get column counting from the end of the row | ||
| (end: -1). For tables that are structured with thead, tbody and tfoot, | ||
| only the tbody section is searched. Please use `Table Header Should Contain` | ||
| or `Table Footer Should Contain` for tests against the header or | ||
| footer content. | ||
|
|
||
| If the table contains cells that span multiple rows, a match | ||
| only occurs for the uppermost row of those merged cells. To | ||
| understand how tables are identified, please take a look at | ||
| the `introduction`. | ||
|
|
||
| See `Page Should Contain Element` for explanation about `loglevel` argument. | ||
| """ | ||
| element = self._table_element_finder.find_by_row(self._current_browser(), table_locator, row, value) | ||
| if element: | ||
| self.log_source(loglevel) | ||
| raise AssertionError("Row #%s in table identified by '%s' should have contained text '%s'." | ||
| % (row, table_locator, value)) | ||
|
|
||
| def table_should_contain(self, table_locator, expected, loglevel='INFO'): | ||
| """Verifies that `expected` can be found somewhere in the table. | ||
|
|
||
|
|
@@ -168,3 +279,18 @@ def table_should_contain(self, table_locator, expected, loglevel='INFO'): | |
| self.log_source(loglevel) | ||
| raise AssertionError("Table identified by '%s' should have contained text '%s'." \ | ||
| % (table_locator, expected)) | ||
|
|
||
| def table_should_not_contain(self, table_locator, value, loglevel='INFO'): | ||
| """Verifies that `expected` should not be present anywhere in the table. | ||
|
|
||
| To understand how tables are identified, please take a look at | ||
| the `introduction`. | ||
|
|
||
| See `Page Should Contain Element` for explanation about | ||
| `loglevel` argument. | ||
| """ | ||
| element = self._table_element_finder.find_by_content(self._current_browser(), table_locator, value) | ||
| if element: | ||
| self.log_source(loglevel) | ||
| raise AssertionError("Table identified by '%s' should not have contained text '%s'." | ||
| % (table_locator, value)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| *** Settings *** | ||
| Documentation Tests table contents for should not keyowrds | ||
| Resource table_resource.robot | ||
| Default Tags table_not_contain | ||
|
|
||
|
|
||
| *** Test Cases *** | ||
| Should Give Error Message When Content Found In Table | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better test name could be: Table Should Not Contain keyword raises correct error when value is found from table |
||
| [Documentation] Should Give Error Message When Content Found In Table | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do repeats what test name says and therefore it is not needed. Remove the documentation. |
||
| [Template] Verify Table Does Contain With CSS And XPath Locators | ||
| simpleTable simpleTable_A1 | ||
| simpleTable simpleTable_C3 | ||
| simpleWithNested simpleWithNested_A1 | ||
| simpleWithNested nestedTable_A1 | ||
| nestedTable nestedTable_A1 | ||
| nestedTable nestedTable_C3 | ||
| tableWithSingleHeader tableWithSingleHeader_B1 | ||
| tableWithSingleHeader tableWithSingleHeader_B2 | ||
| withHeadAndFoot withHeadAndFoot_AH1 | ||
| withHeadAndFoot withHeadAndFoot_B2 | ||
| withHeadAndFoot withHeadAndFoot_CF1 | ||
| mergedRows mergedRows_A1 | ||
| mergedCols mergedCols_B2 | ||
| formattedTable formattedTable_A1 | ||
| formattedTable formattedTable_B1 | ||
| formattedTable formattedTable_C1 | ||
| formattedTable formattedTable_A2 | ||
| formattedTable formattedTable_B2 | ||
| formattedTable formattedTable_ÄÖÜäöüß | ||
| formattedTable äöü€&äöü€& | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there value for table header and footer?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it's already present, it verifies for header, footer and body.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, no changes is needed for that one. |
||
|
|
||
| Test Table Cell Should Not Contain | ||
| [Documentation] Test Table Cell Should Not Contain | ||
| ${table}= set variable simpleTable | ||
| ${row}= set variable 1 | ||
| ${col}= set variable 1 | ||
| ${value} = set variable simpleTable_A2 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the Set Variable only creates not required distraction for the test. It would be cleaner to write: Also use keywords with Title Case Fix in all new test cases. |
||
| table cell should not contain ${table} ${row} ${col} ${value} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be good idea to add line which uses numbers, like: Also test when value is in table header and footer
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should I add a separate test and just add condition to this tests?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What ever feels more natural for you do it. |
||
|
|
||
| Test Table Cell Give Error When Cell Not Present | ||
| [Documentation] Test Table Cell Should Not Contain when Cell is not present in the table | ||
| ${table}= set variable simpleTable | ||
| ${row}= set variable 1 | ||
| ${col}= set variable 10 | ||
| ${value} = set variable simpleTable_A1 | ||
| ${err}= Set Variable Cell in table '${table}' in row #${row} and column #${col} was not found | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Putting error message in variable is OK, because it makes the test more readable. |
||
| Run Keyword And Expect Error ${err} table cell should not contain ${table} ${row} ${col} ${value} | ||
|
|
||
| Test Table Cell Give Error When It Contains | ||
| [Documentation] Test Table Cell Give Error When It Contains | ||
| ${table}= set variable simpleTable | ||
| ${row}= set variable 1 | ||
| ${col}= set variable 1 | ||
| ${value} = set variable simpleTable_A1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. simpleTable_A1 is an exact match, right? Expand test partial text too, example when value is:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also add test when value is in table header and footer. |
||
| ${err}= Set Variable Cell in table '${table}' in row #${row} and column #${col} should not have contained text '${value}'. | ||
| Run Keyword And Expect Error ${err} table cell should not contain ${table} ${row} ${col} ${value} | ||
|
|
||
| Test Table Row Should Not Contain | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Value is an exact match, right? Expand test partial text too. Also add test when value is in table header and footer. |
||
| [Documentation] Test Table Row Should Not Contain | ||
| ${table}= set variable simpleTable | ||
| ${row}= set variable 1 | ||
| ${value} = set variable simpleTable_A2 | ||
| table row should not contain ${table} ${row} ${value} | ||
|
|
||
| Test Table Row Should Give Error When It Contains | ||
| [Documentation] Test Table Row Should Give Error When It Contains | ||
| ${table}= set variable tableWithSingleHeader | ||
| ${value} = set variable tableWithSingleHeader_A1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Value is an exact match, right? Expand test partial text too. Also add test when value is in table header and footer. |
||
| ${row}= set variable 1 | ||
| ${err}= Set Variable Row #${row} in table identified by '${table}' should have contained text '${value}'. | ||
| run keyword and expect error ${err} table row should not contain ${table} ${row} ${value} | ||
|
|
||
| Test Table column Should Not Contain | ||
| [Documentation] Test Table column Should Not Contain | ||
| ${table}= set variable simpleTable | ||
| ${column}= set variable 1 | ||
| ${value} = set variable simpleTable_B2 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Value is an exact match, right? Expand test partial text too. Also add test when value is in table header and footer. |
||
| table column should not contain ${table} ${column} ${value} | ||
|
|
||
| Test Table column Should Give Error When It Contains | ||
| [Documentation] Test Table column Should Give Error When It Contains | ||
| ${table}= set variable tableWithSingleHeader | ||
| ${column}= set variable 1 | ||
| ${value} = set variable tableWithSingleHeader_A1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Value is an exact match, right? Expand test partial text too. Also add test when value is in table header and footer.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value is in the header, should I just rename the test case and add new where value is in footer? or modify this and add condition to verify when value is in footer.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a way that feels the best for your. Both options are fine. |
||
| ${err}= Set Variable Column #${column} in table identified by '${table}' should not have contained text '${value}'. | ||
| run keyword and expect error ${err} table column should not contain ${table} ${column} ${value} | ||
|
|
||
| Test Table Header Should Not Contain | ||
| [Documentation] Test Table Header Should Not Contain | ||
| ${table}= set variable tableWithSingleHeader | ||
| ${value} = set variable tableWithSingleHeader_A3 | ||
| table header should not contain ${table} ${value} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add test when value is table body and table footer but value is not in table header.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the value is in the body. Should I rename this test case to reflect that and add new test case to verify when value is in footer but not in header? or should I rename this test case to reflect both condition where value is in body and footer but not in header and add verification. I can't do that with single value as there is not table where same value is in footer and body but not in header. if you like I can create a new table.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These test can be combined to one test if it feels natural to write test in such way. |
||
|
|
||
| Test Table Header Should Give Error When It Contains | ||
| [Documentation] Test Table Header Should Give Error When It Contains | ||
| ${table}= set variable tableWithSingleHeader | ||
| ${value} = set variable tableWithSingleHeader_A1 | ||
| ${err}= Set Variable Header in table identified by '${table}' should not have contained text '${value}'. | ||
| run keyword and expect error ${err} table header should not contain ${table} ${value} | ||
|
|
||
| Test Table Footer Should Not Contain | ||
| [Documentation] Test Table Footer Should Not Contain | ||
| ${table}= set variable withHeadAndFoot | ||
| ${expected} = set variable withHeadAndFoot_A1 | ||
| table footer should not contain ${table} ${expected} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add test where value is in table header and body.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value withHeadAndFoot_A1 is already in the body, should i just add one more verification where value is not in header and rename the test? or should I rename this test to verify that value is in body but not in footer and then add another test to verify where value is in footer but not in header? |
||
|
|
||
| Test Table Footer Should Give Error When It Contains | ||
| [Documentation] Test Table Footer Should Give Error When It Contains | ||
| ${table}= set variable withHeadAndFoot | ||
| ${value} = set variable withHeadAndFoot_AF1 | ||
| ${err}= Set Variable Footer in table identified by '${table}' should not have contained text '${value}'. | ||
| run keyword and expect error ${err} table footer should not contain ${table} ${value} | ||
|
|
||
|
|
||
| *** Keywords *** | ||
| Verify Table Does Contain With CSS And XPath Locators | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keyword does not have anything to do with the CSS or xpath locators. Better name for keyword could be: Table Should Not Contain keyword raises correct error when value is found from table. |
||
| [Arguments] ${locator} ${value} | ||
| [Documentation] Verify Table Contains With CSS And XPath Locators | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove documentation because it repeats the keyword name. |
||
| ${err}= Set Variable Table identified by '${locator}' should not have contained text '${value}'. | ||
| Run Keyword And Expect Error ${err} Table Should Not Contain ${locator} ${value} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following PEP8[1] is required, fix the line length. Fix only in places where you did provide new code.
[1] https://www.python.org/dev/peps/pep-0008/