Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
264e38c
Added following keywords and their acceptance test cases to fix the i…
Gaurang033 Mar 8, 2016
f8ec2ed
Feature Request - Click Elements #585
Gaurang033 Oct 6, 2016
e66862f
Added method to find element by class name #673
Gaurang033 Oct 13, 2016
8a8f485
Merge remote-tracking branch 'upstream/master'
Gaurang033 Oct 13, 2016
aafe523
Changes to use Firefox ESR (45.4.0)
HelioGuilherme66 Oct 14, 2016
a45ce8d
Changes to use Selenium 2.53.6 (and not 3.0)
HelioGuilherme66 Oct 14, 2016
5ce853c
Added following keywords and their acceptance test cases to fix the i…
Gaurang033 Mar 8, 2016
25982b4
Fixes `Unselect From List` due to Selenium changes.
HelioGuilherme66 Apr 29, 2016
b29f5f3
CONTRIBUTING.md file to how to make pull request
aaltat Sep 11, 2015
b6de053
Edge browser compatibility
jfx Jan 11, 2016
562bc6d
Fixes #257 by removing the docutils dependency
aaltat Aug 8, 2016
0604fbd
Changed AUTHORS.txt to CHANGES.rst in CONTRIBUTING.md
aaltat Aug 8, 2016
91cb8c0
Fixes #629 by expecting NoSuchElementException (#630)
aaltat Aug 22, 2016
9bba151
Bump version 1.8.0
aaltat Aug 22, 2016
2ed8a63
Generated documentation only needed in gh-pages branch
aaltat Aug 22, 2016
aadfca0
Moving library documentation from doc to docs
aaltat Aug 22, 2016
8d8b471
Creates docs/index.html
pekkaklarck Aug 22, 2016
672768d
Fixed README.rst to point new keyword documentation location
aaltat Aug 22, 2016
88cb6fe
Removed not needed doc folder
aaltat Aug 22, 2016
ae3c313
Removes the project demo and points to joint project with RF
aaltat Aug 22, 2016
e3d301b
Removed README on favor of README.rst
aaltat Aug 22, 2016
3ab9b3c
Add note about new keyword doc location
pekkaklarck Aug 23, 2016
5662c74
Release notes for 1.8.0 release
aaltat Aug 24, 2016
9aef125
Remove ez_setup.py and references to it in setup.py. (#647)
pekkaklarck Sep 5, 2016
439dae7
Print fix (#626)
Sep 5, 2016
f3f40cd
Remove vendored mockito and list in requirements-dev.txt instead. (#660)
pekkaklarck Sep 6, 2016
97f817a
Add requirements.txt. (#659)
pekkaklarck Sep 6, 2016
3f578e7
Clean up run_unit_tests.py. (#662)
pekkaklarck Sep 8, 2016
3b7c14f
Fix alerts on chrome (#661)
aaltat Sep 16, 2016
57b9971
Libdoc updates - link to project and fix 404 (#668)
ombre42 Oct 9, 2016
80f6190
Changes to use Firefox ESR (45.4.0)
HelioGuilherme66 Oct 14, 2016
320f0ae
Changes to use Selenium 2.53.6 (and not 3.0)
HelioGuilherme66 Oct 14, 2016
382fc57
Merge branch 'master' of https://github.com/Gaurang033/Selenium2Library
Gaurang033 Oct 14, 2016
486d4d8
Merge remote-tracking branch 'upstream/master'
Dec 30, 2016
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
13 changes: 13 additions & 0 deletions src/Selenium2Library/keywords/_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,3 +815,16 @@ def _page_should_not_contain_element(self, locator, tag, message, loglevel):
raise AssertionError(message)
self._info("Current page does not contain %s '%s'."
% (element_name, locator))

def click_elements(self, locator):
"""
Clicks all the elements identified by `locator`.

Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
"""
elements = self._element_find(locator, False, True)
self._info("total %s elements found with matching locator %s" % (len(elements), locator))
self._info("clicking on all elements found with matching locator %s" % locator)
for element in elements:
element.click()
127 changes: 127 additions & 0 deletions src/Selenium2Library/keywords/_tableelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, expected, loglevel='INFO'):
"""
Verifies that a certain cell in a table does not contain `expected`.

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, expected))
try:
content = self.get_table_cell(table_locator, row, column, loglevel='NONE')
except AssertionError, err:
self._info(err)
self.log_source(loglevel)
raise AssertionError(message)
self._info("Cell contains %s." % content)

if expected 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`.

Expand Down Expand Up @@ -100,6 +131,33 @@ 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, expected, 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, expected)
if element is not None:
self.log_source(loglevel)
raise AssertionError("Column #%s in table identified by '%s' "
"should not have contained text '%s'."
% (col, table_locator, expected))

def table_footer_should_contain(self, table_locator, expected, loglevel='INFO'):
"""Verifies that the table footer contains `expected`.

Expand All @@ -116,6 +174,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, expected, 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, expected)
if element is not None:
self.log_source(loglevel)
raise AssertionError("Footer in table identified by '%s' should not have contained "
"text '%s'." % (table_locator, expected))

def table_header_should_contain(self, table_locator, expected, loglevel='INFO'):
"""Verifies that the table header, i.e. any <th>...</th> element, contains `expected`.

Expand All @@ -131,6 +205,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, expected, 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, expected)
if element is not None:
self.log_source(loglevel)
raise AssertionError("Header in table identified by '%s' should not have contained "
"text '%s'." % (table_locator, expected))

def table_row_should_contain(self, table_locator, row, expected, loglevel='INFO'):
"""Verifies that a specific table row contains `expected`.

Expand All @@ -154,6 +243,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, expected, 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, expected)
if element is not None:
self.log_source(loglevel)
raise AssertionError("Row #%s in table identified by '%s' should have contained "
"text '%s'." % (row, table_locator, expected))

def table_should_contain(self, table_locator, expected, loglevel='INFO'):
"""Verifies that `expected` can be found somewhere in the table.

Expand All @@ -168,3 +280,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, expected, 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, expected)
if element is not None:
self.log_source(loglevel)
raise AssertionError("Table identified by '%s' should not have contained text '%s'." \
% (table_locator, expected))
8 changes: 8 additions & 0 deletions test/acceptance/keywords/click_element.robot
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ Double Click Element
Double Click Element doubleClickButton
Element Text Should Be output double clicked

Click All Element
[Documentation] Test Click Elements keyword
Go To Page "forms/prefilled_email_form.html"
Click Elements //*[@type='checkbox']
checkbox should not be selected can_send_email
Checkbox Should Be Selected can_send_sms
Go To Page "javascript/click.html"

*** Keywords ***
Initialize Page
[Documentation] Initialize Page
Expand Down
111 changes: 111 additions & 0 deletions test/acceptance/keywords/tables/table_should_not_contain.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
*** 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
[Documentation] Should Give Error Message When Content Found In Table
[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 äöü€&äöü€&

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
${expected} = set variable simpleTable_A2
table cell should not contain ${table} ${row} ${col} ${expected}

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
${expected} = set variable simpleTable_A1
${err}= Set Variable Cell in table '${table}' in row #${row} and column #${col} should not have contained text '${expected}'.
Run Keyword And Expect Error ${err} table cell should not contain ${table} ${row} ${col} ${expected}

Test Table Row Should Not Contain
[Documentation] Test Table Row Should Not Contain
${table}= set variable simpleTable
${row}= set variable 1
${expected} = set variable simpleTable_A2
table row should not contain ${table} ${row} ${expected}

Test Table Row Should Give Error When It Contains
[Documentation] Test Table Row Should Give Error When It Contains
${table}= set variable tableWithSingleHeader
${expected} = set variable tableWithSingleHeader_A1
${row}= set variable 1
${err}= Set Variable Row #${row} in table identified by '${table}' should have contained text '${expected}'.
run keyword and expect error ${err} table row should not contain ${table} ${row} ${expected}

Test Table column Should Not Contain
[Documentation] Test Table column Should Not Contain
${table}= set variable simpleTable
${column}= set variable 1
${expected} = set variable simpleTable_B2
table column should not contain ${table} ${column} ${expected}

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
${expected} = set variable tableWithSingleHeader_A1
${err}= Set Variable Column #${column} in table identified by '${table}' should not have contained text '${expected}'.
run keyword and expect error ${err} table column should not contain ${table} ${column} ${expected}

Test Table Header Should Not Contain
[Documentation] Test Table Header Should Not Contain
${table}= set variable tableWithSingleHeader
${expected} = set variable tableWithSingleHeader_A3
table header should not contain ${table} ${expected}

Test Table Header Should Give Error When It Contains
[Documentation] Test Table Header Should Give Error When It Contains
${table}= set variable tableWithSingleHeader
${expected} = set variable tableWithSingleHeader_A1
${err}= Set Variable Header in table identified by '${table}' should not have contained text '${expected}'.
run keyword and expect error ${err} table header should not contain ${table} ${expected}

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}

Test Table Footer Should Give Error When It Contains
[Documentation] Test Table Footer Should Give Error When It Contains
${table}= set variable withHeadAndFoot
${expected} = set variable withHeadAndFoot_AF1
${err}= Set Variable Footer in table identified by '${table}' should not have contained text '${expected}'.
run keyword and expect error ${err} table footer should not contain ${table} ${expected}


*** Keywords ***
Verify Table Does Contain With CSS And XPath Locators
[Arguments] ${locator} ${expected}
[Documentation] Verify Table Contains With CSS And XPath Locators
${err}= Set Variable Table identified by '${locator}' should not have contained text '${expected}'.
Run Keyword And Expect Error ${err} Table Should Not Contain ${locator} ${expected}