Skip to content

issue #463 - #724

Closed
Gaurang033 wants to merge 4 commits into
robotframework:masterfrom
Gaurang033:feature-table-functions
Closed

Gaurang033 wants to merge 4 commits into
robotframework:masterfrom
Gaurang033:feature-table-functions

Conversation

@Gaurang033

Copy link
Copy Markdown
Contributor

…ssue #463

table_cell_should_not_contain
table_column_should_not_contain
table_footer_should_not_contain
table_header_should_not_contain
table_row_should_not_contain
table_should_not_contain

…ssue robotframework#463

table_cell_should_not_contain
table_column_should_not_contain
table_footer_should_not_contain
table_header_should_not_contain
table_row_should_not_contain
table_should_not_contain

@aaltat aaltat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice code in new keywords looks quite OK. There are some updates needed, but they do not need big refactoring. I did not read acceptance test, but I will read those in near future.

self.log_source(loglevel)
raise AssertionError(message)

def table_cell_should_not_contain(self, table_locator, row, column, expected, loglevel='INFO'):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all the new code, try to follow pep8 maximum line length: https://www.python.org/dev/peps/pep-0008/#maximum-line-length. Fix in all places where it is exceeded in code which you have written. You do not need fix the existing code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps expected is not good argument name, because we expect that string is not there. Could not_contain or value be better argument names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have kept all the arguments name same as other functions in the file to keep the consistency, if like I can change that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change only argument name only for new keywords. Changing the old ones would be backwards incompatible change and I am reluctant to do so.

except AssertionError, err:
self._info(err)
self.log_source(loglevel)
raise AssertionError(message)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception text is not correct. It should say that:
Cell in table '%s' in row #%s and column #%s was not found

But the text is correct for the exception in line 105.

% (table_locator, row, column, expected))
try:
content = self.get_table_cell(table_locator, row, column, loglevel='NONE')
except AssertionError, err:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write:
except AssertionError as err:
that is supported by Python 2 and Python 3

`loglevel` argument.
"""
element = self._table_element_finder.find_by_col(self._current_browser(), table_locator, col, expected)
if element is not None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more Python way to write:
if not element:

self.log_source(loglevel)
raise AssertionError("Column #%s in table identified by '%s' "
"should not have contained text '%s'."
% (col, table_locator, expected))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is not following pep8.

self.log_source(loglevel)
raise AssertionError(message)
self._info("Cell contains %s." % content)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line is not needed.

`loglevel` argument.
"""
element = self._table_element_finder.find_by_footer(self._current_browser(), table_locator, expected)
if element is not None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more Python way to write:
if not element:

`loglevel` argument.
"""
element = self._table_element_finder.find_by_header(self._current_browser(), table_locator, expected)
if element is not None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more Python way to write:
if not element:

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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more Python way to write:
if not element:

`loglevel` argument.
"""
element = self._table_element_finder.find_by_content(self._current_browser(), table_locator, expected)
if element is not None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more Python way to write:
if not element:

@aaltat

aaltat commented Jan 3, 2017

Copy link
Copy Markdown
Contributor

Also you can add your name to the https://github.com/robotframework/Selenium2Library/blob/master/BUILD.rst file if you want credit.

@Gaurang033

Copy link
Copy Markdown
Contributor Author

@aaltat I am not sure what you mean by the following comment.

Also you can add your name to the https://github.com/robotframework/Selenium2Library/blob/master/BUILD.rst file if you want credit.

@aaltat

aaltat commented Jan 5, 2017

Copy link
Copy Markdown
Contributor

You can add, if you want, your name to the file and short description what you have done.

@aaltat

aaltat commented Jan 5, 2017

Copy link
Copy Markdown
Contributor

Ah but the file was wrong, here the correct file https://github.com/robotframework/Selenium2Library/blob/master/CHANGES.rst

@Gaurang033

Copy link
Copy Markdown
Contributor Author

@aaltat That's what I was wondering. Should I mentioned the changes under 1.8.1 or create the new section 1.8.2 and mentioned under that?

@aaltat

aaltat commented Jan 5, 2017

Copy link
Copy Markdown
Contributor

1.8.1 is the right one, it should actually say next release.

@aaltat

aaltat commented Jan 11, 2017

Copy link
Copy Markdown
Contributor

Is that TODO comment valid one?

@aaltat

aaltat commented Jan 11, 2017

Copy link
Copy Markdown
Contributor

Could you remove the comment then? This week is busy but I hope that I time in the weekend to read the code

@aaltat aaltat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the ToDo comment

% (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))
# TODO new message as per comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line indicates that PR is not ready.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the comment, because it looks invalid

@aaltat

aaltat commented Feb 1, 2017

Copy link
Copy Markdown
Contributor

There are some comments for the test.


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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Join lines 77 and 78 as a single line.

self.log_source(loglevel)
raise AssertionError(message)

def table_cell_should_not_contain(self, table_locator, row, column, value, loglevel='INFO'):

Copy link
Copy Markdown
Contributor

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/


*** Test Cases ***
Should Give Error Message When Content Found In Table
[Documentation] Should Give Error Message When Content Found In Table

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

*** Keywords ***
Verify Table Does Contain With CSS And XPath Locators
[Arguments] ${locator} ${value}
[Documentation] Verify Table Contains With CSS And XPath Locators

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove documentation because it repeats the keyword name.



*** Keywords ***
Verify Table Does Contain With CSS And XPath Locators

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 column Should Not Contain
${table}= set variable simpleTable
${column}= set variable 1
${value} = set variable simpleTable_B2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 column Should Give Error When It Contains
${table}= set variable tableWithSingleHeader
${column}= set variable 1
${value} = set variable tableWithSingleHeader_A1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Create test when value is not in header, body or footer, like with tidii or something.
  2. Test when value is in body (the current test)
  3. Create test when value is in footer.

These test can be combined to one test if it feels natural to write test in such way.

[Documentation] Test Table Footer Should Not Contain
${table}= set variable withHeadAndFoot
${expected} = set variable withHeadAndFoot_A1
table footer should not contain ${table} ${expected}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test where value is in table header and body.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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?

@aaltat

aaltat commented Apr 22, 2019

Copy link
Copy Markdown
Contributor

Closing due inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants