Skip to content
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

Merged
merged 4 commits into from
Nov 6, 2019
Merged

Conversation

digitronik
Copy link
Member

@digitronik digitronik commented Aug 19, 2019

Signed-off-by: Nikhil Dhandre [email protected]

  • We are facing problem with browser windows handling.
  • Its possible with core selenium call so wrapping thing for browser

ManageIQ/integration_tests#9195

@digitronik digitronik changed the title [WIPT] browser windows handling [WIP] browser windows handling Aug 19, 2019
@digitronik
Copy link
Member Author

digitronik commented Aug 19, 2019

aaaaaaahhh its due to monotonic attribute of time. Ignore travis is going to fix in Mike PR https://github.com/RedHatQE/widgetastic.core/pull/156/files

Signed-off-by: Nikhil Dhandre <[email protected]>
@digitronik digitronik changed the title [WIP] browser windows handling [RFR] browser windows handling Aug 20, 2019
@izapolsk izapolsk self-requested a review August 20, 2019 08:04
Copy link
Collaborator

@mshriver mshriver left a 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.

@mshriver
Copy link
Collaborator

@digitronik Please write some unit tests for all of these functions.

Signed-off-by: Nikhil Dhandre <[email protected]>
@digitronik
Copy link
Member Author

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

def title(self):
"""Returns current title"""
result = self.selenium.title
self.logger.info('current title -> %r', result)
Copy link
Collaborator

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'

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@izapolsk izapolsk left a 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.

@property
def title(self):
"""Returns current title"""
result = self.selenium.title
Copy link
Contributor

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

src/widgetastic/browser.py Show resolved Hide resolved
Signed-off-by: Nikhil Dhandre <[email protected]>


def test_current_window_handle(browser):
assert browser.title == "Test page"
Copy link
Collaborator

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.

Copy link
Member Author

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


def test_window_handles(request, browser):
assert len(browser.window_handles) == 1
handle = browser.new_window(url="http://example.com")
Copy link
Collaborator

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.

Copy link
Member Author

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

@digitronik
Copy link
Member Author

@mshriver changes added

def title(self):
"""Returns current title"""
current_title = self.selenium.title
self.logger.info('Current title: %r', current_title)
Copy link

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?

Copy link
Contributor

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.

@mshriver mshriver merged commit d854e92 into RedHatQE:master Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants