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

Philimon/suite refactor #445

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Conversation

philimon-reset
Copy link
Collaborator

Description

General Improvement of the find_toolbar and pdf_viewer test suites.
This includes improvements to the GenericPDF, Navigation, and FindToolbar object models.

Bugzilla bug ID: 1935748

Testrail:
Link: Points of Improvment.pdf

Type of change

  • Other Changes (Please specify)

How does this resolve / make progress on that bug?

Clean up to improve the tests' and object models' readability and clarity.

Comments / Concerns

Test improvements include clean-up, moving context switches to decorators, moving large functionalities to object models, and more.

@philimon-reset philimon-reset self-assigned this Feb 6, 2025
@philimon-reset philimon-reset removed the request for review from ben-c-at-moz February 6, 2025 14:36
yield find_toolbar


@pytest.fixture()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may be for much later but...we might want to do away with BrowserActions at some point, and either way, I probably shouldn't have gotten in the habit of calling it ba in tests. So maybe we'll work on this part a bit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes a lot of sense. Most methods can be moved to the page_base or the corresponding BOM. For now, I can rename the instance fixture to be more descriptive of what it is.

@@ -103,6 +104,28 @@ def set_chrome_context(self):
if self._xul_source_snippet not in self.driver.page_source:
self.driver.set_context(self.driver.CONTEXT_CHROME)

@staticmethod
Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome way of solving the problem.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted to go further with it to enable the BOM method to work by default in the Chrome context but faced some difficulties. I'd like to get it working for the next round of improvements.



def test_find_toolbar_navigation(driver: Firefox):
def are_lists_different(a: int, b: int) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a good rename

"""
C127249: Navigate through found items

Arguments:
ba: instantiation of BrowserActions BOM.
Copy link
Collaborator

Choose a reason for hiding this comment

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

BrowserActions isn't strictly a BOM. Let's talk about BrowserActions sometime, I do think it might be worth considering eliminating it and merging it with BasePage

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Definitely Agree

@@ -2,10 +2,13 @@
from time import sleep

import pytest
from pynput.keyboard import Controller
Copy link
Collaborator

Choose a reason for hiding this comment

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

So I know that it's standard to import everything at the top, but in the case of pynput, we really don't want to do that--the simple act of importing pynput on a *nix system without a DISPLAY env var set causes a crash.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I suspected there was a reason the import wasn't at the top. my bad, should have asked before the change 😅

):
"""
C3932: PDF files can be successfully downloaded via pdf.js


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 also talk about whether we need args in the docstring for tests. I can see it both ways, and I want to decide what are the criteria for inclusion in the docstring.

Copy link
Collaborator Author

@philimon-reset philimon-reset Feb 11, 2025

Choose a reason for hiding this comment

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

Thats fair. Some comments on the parameters are necessary though, especially until we reach a point where we all have descriptive parameters. But we could skip the repeated parameters like driver since we all know what it is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, that's a good point



def zoom_pdf_viewer(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this should move to the GenericPdf POM or to the pdf_viewer conftest? Seems like a generic function that may be needed in future tests...

numeric_field.send_keys(test_value + Keys.TAB)
numeric_field = pdf.get_element("zipcode-field")
numeric_field.clear()
numeric_field.send_keys("12345" + Keys.TAB)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a reason to move the constant test value out of the variable and into two different lines? Open to it, but would love to know the rationale

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