-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[py] Refactored conftest.py
in a more object oriented design approach
#15495
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
base: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
conftest.py
in a more object oriented design approachconftest.py
in a more object oriented design approach
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.
@sandeepsuryaprasad thanks for the PR! Overall this looks really nice.
I pulled your branch and ran some tests, and noticed that the browser now closes and re-opens between every test. Previously, it was re-using the same browser instance between tests.
For example, if you run pytest py/test/selenium/webdriver/common/typing_tests.py
you will notice this. The same tests running against trunk behave different. This makes the tests take significantly longer to run. Can you look into that and make it so it behaves like it used to?
Also, the AI bot found some minor issues. Could you address these?:
#15495 (comment)
There are some |
@cgoldberg sure.. I figured out what went wrong.. I will fix it and push the code once agin. |
@sandeepsuryaprasad great, I'll give it another look once you update. |
@sandeepsuryaprasad I tried again after your latest changes and there are still issues.
If I try to run tests with the argument Similarly, if I run tests with the argument
I haven't looked into what is causing these, but they need to be fixed before we can merge this. |
@cgoldberg I am working on it..running tests on my local machine.. |
@cgoldberg can you try it now.. except remote tests all other tests are passing when I run CI on my machine. Regarding closing and re-opening of the browser for every test, the scope of the fixture |
@sandeepsuryaprasad The issues I mentioned in my last comment are still there... I don't see any changes that fix them. As far as the browser closing/re-opening... I haven't investigated the cause, but it didn't do that before (run the tests against trunk to see). We don't want to introduce that change, so it needs to function the same way as it did previously. |
@cgoldberg I have fixed
|
@cgoldberg working on browser closing/re-opening issue. |
@cgoldberg Looks like there is some bug in the below code that I have taken from But the variable
If you carefully observe the execution, except for the above tests, for all other tests a new instance of chrome opens (setup part) and closes (teardown part,
But in the PR that I have raised, the teardown part
Please let me know your thoughts on this. Thanks! |
bbc6444
to
2c5d02f
Compare
2c5d02f
to
1e518ac
Compare
@cgoldberg I have fixed all the review comments. After the code change in this PR, the behaviour is exactly same as it was on trunk. Can you please re-trigger the CI. I have executed all tests on my local and it's passing.
|
I just triggered CI again. |
a4b0eb6
to
3caaf8c
Compare
@cgoldberg I have modified the code, introduced one more level of abstraction for handling driver classes and options classes. Please let me know your feedback. I ran all the tests on my local and it's passing. |
@sandeepsuryaprasad I realized that the issue I brought up in my last comment exists in the current (trunk) code. I fixed it in a separate PR that was just merged. See PR #15550 for details. This will cause conflicts with your branch. Could you please roll back your latest commit and incorporate the changes I made that are now in trunk? Thanks. |
c695a01
to
eddf963
Compare
8a5c71e
to
053a201
Compare
92efe94
to
52804cb
Compare
@cgoldberg I have resolved the conflicts and committed the latest changes. All tests are passing in local. Now the driver classes and option classes are being maintained in a separate class just to get rid of driver class hassle. Please let me know your feedback on this. |
1d41b46
to
d343f3d
Compare
@cgoldberg done! now I am catching |
@cgoldberg can you trigger CI for this one please. |
CI is running now. |
@cgoldberg I took a look at the results.. tests are passing apart from 3 flaky tests
|
@cgoldberg can we have this PR merged to the main trunk. Thanks! |
@cgoldberg there is no change in the test results.. except for those 3 flakey tests, others are passing.. I think we can merge this PR to main trunk. |
@cgoldberg can you please get this one merged.. or is there anything that needs to be changed from my end. There was one merge conflict.. I have resolved it.. |
@cgoldberg I have resolved the merge conflicts.. I have included the Firefox change from trunk to the current branch. |
@cgoldberg can we have this one merged if everything is okay. |
@sandeepsuryaprasad I need to take a look again and decide if this PR improves things or just adds complexity. I will update this issue once I get a chance. |
There are 2 failures in CI. The error coming from However, the other one ( Can you take a look? Note: this is a new test covering new functionality, so I'm not that familiar with it yet... but it only fails in your branch. Also, the test seems to pass if I run it alone, but fails when I run the full test file, so it leads me to believe there is something wrong in one of the pytest fixtures.
|
@cgoldberg sure... I will take a look at that test... I will update on that. |
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Refactored
conftest.py
in a more object oriented design approachMotivation and Context
Refactored
conftest.py
in a more object oriented design approach so that the code is more readable and easy to make changes in the future.Types of changes
Checklist
PR Type
Enhancement
Description
Refactored
conftest.py
to an object-oriented design for better readability.Introduced a
Driver
class to encapsulate driver-related logic and properties.Simplified driver initialization and teardown using the
Driver
class.Removed redundant functions and streamlined driver configuration handling.
Changes walkthrough 📝
conftest.py
Refactored `conftest.py` with a `Driver` class
py/conftest.py
Driver
class to encapsulate driver logic.design.