-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[py][bidi]: add enable_webextensions
option for chromium-based browsers
#15794
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
[py][bidi]: add enable_webextensions
option for chromium-based browsers
#15794
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Is there a better way to directly use the |
@oliverdunk can you have a look at this PR? |
I guess the issue is that you don't want to add You could create the driver in the test and not use the fixture. We do that in a few tests. You could add a new fixture similar to the It's not a great solution, but I think it will help. (let me know if that's not a good explanation) |
@cgoldberg I have added a new pytest marker |
enable_webextensions
method for chrome bidienable_webextensions
option for chromium-based browsers
I agree with this - I don't think the new marker or conftest changes are necessary. We can create a driver specifically for the webextension tests, and then put a xfail_firefox marker (e.g. with reason "not implemented") on those tests for now. You can wrap the webextension tests in a test class to make this easier. |
Will the new driver be created inside the webextension test file or Edit: Extension is loaded but |
The solution I'm suggesting would create it within the test. It's going to be difficult to have a common test that supports all browsers. I would write a test for Firefox (that's skipped by other browsers) and one for Chrome/Edge (that's skipped by other browsers). For an example, look at |
@cgoldberg yes, I am trying it as you described above. I noticed one issue right now which results in my tests getting failures, while launching the driver, it opens 2 browser windows, extension installation is successful and when I do I am trying to fix this. |
I think chromium_driver.get("https://www.webpagetest.org/blank.html") @cgoldberg @shbenzer can you please have a look and see if something can be done so that pages.load work as expected. |
the pages fixture is defined in conftest.py as the following: @pytest.fixture
def pages(driver, webserver):
class Pages:
def url(self, name, localhost=False):
return webserver.where_is(name, localhost)
def load(self, name):
driver.get(self.url(name))
return Pages() You're correct. The problem is this uses the initial driver - you'll need to create your own Pages class if you wish to use this functionality |
@shbenzer I guess that will be a lot of changes to do just for a single test file, also we have an issue in running this multi driver approach in CI-RBE which is giving a |
I don't think it's a big deal adding the class in if you'll use it, but do what you think is best. With regards to the error you're seeing in RBE:
You gotta love when an error message uses "probably"... You could try creating a temporary directory then setting it in chromium_driver's options with something like |
@navin772 That In your tests, you are instantiating I don't think the |
It does work because I will try to move the fixture to |
Posting the same comment I posted on Slack: Actually, ChatGPT helped me understand why this happens.
This is how I fixed it in our docs examples. |
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.
LGTM 👍
is this ready to be merged? Let me know and I'll pull the trigger.
User description
🔗 Related Issues
More info - #15749 (comment)
💥 What does this PR do?
Chrome requires 2 flags for BiDi webextensions to work:
--remote-debugging-pipe
--enable-unsafe-extension-debugging
This PR adds a chrome option to enable these flags easily -
enable_webextensions
User can either use the above chrome option or add the flags manually.
The
webExtension.install
method will return an exception if the user forgets to add these flags.Usage:
OR directly pass the flags
🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement, Tests
Description
Adds
enable_webextensions
option to Chrome for BiDi webextensionsImproves error handling in
webExtension.install
for missing flagsUpdates and documents BiDi webextension test for Chrome
Updates test configuration to enable webextensions for Chrome BiDi
Changes walkthrough 📝
options.py
Add `enable_webextensions` property to Chrome options
py/selenium/webdriver/chrome/options.py
enable_webextensions
property with getter/settersupport
webextension.py
Improve error handling for Chrome webextension install
py/selenium/webdriver/common/bidi/webextension.py
bidi_webextension_tests.py
Update and document BiDi webextension test for Chrome
py/test/selenium/webdriver/common/bidi_webextension_tests.py
conftest.py
Enable Chrome webextensions in BiDi test configuration
py/conftest.py