-
Notifications
You must be signed in to change notification settings - Fork 44
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
[RFR] browser windows handling #157
Conversation
aaaaaaahhh its due to |
Signed-off-by: Nikhil Dhandre <ndhandre@redhat.com>
1a884e8
to
8dd9420
Compare
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.
Thanks for addressing this @digitronik! Clean code, thanks for writing docblocks from the start.
Let's discuss some additional functionality for this first iteration of window handling, but I don't think any major changes from what you have here.
@digitronik Please write some unit tests for all of these functions. |
Signed-off-by: Nikhil Dhandre <ndhandre@redhat.com>
@mshriver I added unit tests for current implementation of windows handling. I tried other as well but I think it will effect more and may be break other dependent projects so adding issue for that idea. |
src/widgetastic/browser.py
Outdated
def title(self): | ||
"""Returns current title""" | ||
result = self.selenium.title | ||
self.logger.info('current title -> %r', result) |
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.
Please use more consistent log formatting here, note the logging for the url
properties. Should be 'Current title: %r'
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.
done
2d98275
to
f4e5272
Compare
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.
looks good so far.
there is one concern though. I think we need to implement Window widget and wrap every window handle into such class.
src/widgetastic/browser.py
Outdated
@property | ||
def title(self): | ||
"""Returns current title""" | ||
result = self.selenium.title |
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.
please use self descriptive names for variables
Signed-off-by: Nikhil Dhandre <ndhandre@redhat.com>
f4e5272
to
30f6c14
Compare
|
||
|
||
def test_current_window_handle(browser): | ||
assert browser.title == "Test 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.
Please write some docblocs for these tests, stating what component of window handling they're covering.
This case looks more like a test of the new title attribute than it is a test of current_window_handle, which is tested in test_window_handles below anyway.
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.
Added separate tests for each method... with small doc block. 👍
testing/test_browser.py
Outdated
|
||
def test_window_handles(request, browser): | ||
assert len(browser.window_handles) == 1 | ||
handle = browser.new_window(url="http://example.com") |
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.
let's not include actual HTTP requests, and name resolution, in the unit tests.
Use the test_server fixture to just open another window to the testing page, hosted locally.
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.
moved to test_server.url
@mshriver changes added |
def title(self): | ||
"""Returns current title""" | ||
current_title = self.selenium.title | ||
self.logger.info('Current title: %r', current_title) |
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.
Could we use f strings
here?
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 wouldn't do that. 1. f-strings will limit wt.core to py 3.6+ ; 2. logger module has its own syntax for logging statements.
Signed-off-by: Nikhil Dhandre ndhandre@redhat.com
selenium call
so wrapping thing for browserManageIQ/integration_tests#9195