-
Notifications
You must be signed in to change notification settings - Fork 781
Mega super hyper cleanup #956
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
Conversation
- Enhance documentation of ElementKeywords (robotframework#925). - Add '.' at the end of error and log messages. - Introduce `ContextsAware.find_elements` helper. - Change default value of optional `message` from '' to None. - Use `is_noney` instead of `is_falsy` when default value is None. - General (and trivial) cleanup to code and tests.
Also added more XPath examples. This ought to cover enhancements proposed by robotframework#940.
- Doc string to `find_element`. Mainly to give type hits to IDE but higher level APIs should get more docs in general. - Introduced ElementNotFound error that `ElementFinder.find` uses. - Move helpers to ContextAware and LibraryComponent to avoid unnecessary coupling between different library componets. - Remove unnecessary helpers when `find_element(locator).method()` works as well. - Rewriter internal logic with `Wait` keywords. This includes consistently handling non-existing elements. - Make unregistering strategy that hasn't been registered an error. - Consider `<input type="file">` text element consistently. - General cleanup here and there.
|
Did only read to waiting object, but have few comments |
"Element Should (Not) Be Enabled" and "Wait Until Element Is Enabled" now all validate that the element is enabled and not readonly. Also removed broken element type validation from the former keywords. Fixes robotframework#958.
aaltat
left a comment
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.
Did all the changes.
| @keyword | ||
| def current_frame_should_not_contain(self, text, loglevel='INFO'): | ||
| """Verifies that current frame contains `text`. | ||
| """Verifies that current frame contains ``text``. |
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.
Should there be not somewhere in the sentence?
|
|
||
| @keyword | ||
| def current_frame_should_not_contain(self, text, loglevel='INFO'): | ||
| """Verifies that current frame contains ``text``. |
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.
I think doc string is missing text: not
| try: | ||
| if condition(): | ||
| return | ||
| except ElementNotFound as err: |
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.
I was thinking that this code could resolve the StaleElementReferenceException if we would suppress also that exception. If it does, perhaps we should look us there other exceptions that could be also suppress.
src/SeleniumLibrary/errors.py
Outdated
| # limitations under the License. | ||
|
|
||
|
|
||
| class ElementNotFound(Exception): |
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.
Having own exception is really good idea.
I think in future it is possible that we have more exceptions and because it provides better information for the user. But for programmatic, I often have to need suppress all from specific class. Therefore it might be useful to have some base error class for SeleniumLibrary exceptions. Like:
class BaseException(Exception):
ROBOT_SUPPRESS_NAME = True
class ElementNotFound(BaseException):
pass
Then in libraries which extend SL, I could do:
try:
self.sl.some_method(arg1, arg2...)
expect BaseException:
do_something_else(ar3)
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.
Good idea. I'll add SeleniumLibraryException base class.
| using the log level specified with the optional ``loglevel`` | ||
| argument. Valid log levels are ``DEBUG``, ``INFO`` (default), | ||
| ``WARN``, and ``NONE``. If the log level is ``NONE`` or below | ||
| the current active log level the source will not be logged. |
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.
It might be useful to mention that text is verified from the DOM tree which sometimes may differ what is seen in the page. Example the case of the text might be different in the DOM, than what is seen in the page. Other valid example if the text is split to multiple elements, example there is link in the middle of the text, then keyword can not find the whole text. Instead the search must be divided between each element.
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.
Are you sure about the problem with finding text with elements in them? I just changed our test data to contain This is the haystack and somewhere on this page is a <em>needle</em>. and
Page Should Contain This is the haystack and somewhere on this page is a needle.
seems to work just fine.
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.
I did have recollection that in some point it did not work, but I ques it does not hold water anymore. But the first point is a valid one and sometimes causes questions in the user group or in the issue tracker.
| def page_should_not_contain_link(self, locator, message='', loglevel='INFO'): | ||
| """Verifies image identified by `locator` is not found from current page. | ||
| def page_should_not_contain_link(self, locator, message=None, loglevel='INFO'): | ||
| """Verifies image identified by ``locator`` is not found from current page. |
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.
change "image" to "link"
|
|
||
| @keyword | ||
| def wait_until_element_is_enabled(self, locator, timeout=None, error=None): | ||
| """Waits until element specified with `locator` is enabled. |
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.
`locator ` to ``locator``
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.
I haven't gone through these docs yet.
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.
No problem.
| Fails if `timeout` expires before the element is enabled. See | ||
| `introduction` for more information about `timeout` and its | ||
| Fails if `timeout` expires before the element is enabled. Element |
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.
`timeout` to ``timeout``
| See `introduction` for more information about `timeout` and its | ||
| default value. | ||
| `error` can be used to override the default error message. |
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.
`error` to ``error``
| else: | ||
| del self._strategies[strategy_name] | ||
| if strategy_name not in self._strategies: | ||
| raise RuntimeError("Cannot unregister the non-registered strategy '%s'." |
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.
Should there be issue about this change? It by a quick look feels backwards incompatible change.
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.
I guess so. Submitted #961.
- User `find_elements` instead of `find_element` when possible. - Avoid `strategy=value` locator syntax in code. - Enhance error messages when radio buttons not found. - Cleanup `Choose File` test and test it with Firefox. - TableElementFinder._locator to public class variable. - Remove useless documentation.
Cleanup to docs and code here and there. See commit messages of individual commits for details. Sorry for some of the commits grewing unfortunately large.