[py][bidi]: add enable_webextensions option for chromium-based browsers#15794
[py][bidi]: add enable_webextensions option for chromium-based browsers#15794cgoldberg merged 18 commits intoSeleniumHQ:trunkfrom
enable_webextensions option for chromium-based browsers#15794Conversation
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 |
|
Just a note on this: https://developer.chrome.com/blog/remote-debugging-port So Also note: |
That’s a great note - we should definitely advise users about this in the docstring and the docs. I’ll make a pr real quick |
| self.add_argument(flag) | ||
| else: | ||
| # Remove webextension flags if disabling | ||
| flags_to_remove = ["--enable-unsafe-extension-debugging", "--remote-debugging-pipe"] |
There was a problem hiding this comment.
Just wanted to note that from my reading of the --remote-debugging-pipe description it is not exclusively a webextension command line switch. So if one adds it separately and chooses to disable web extensions via this method, as in,
options = webdriver.ChromeOptions()
options.add_argument("--remote-debugging-pipe")
options.enable_webextensions = Falseit will negate that command line switch and might be tough to debug. Probably the method documentation should note that disabling removes both switches.
There was a problem hiding this comment.
This was discussed but no conclusion was made - #15794 (comment), what do you think would be the best way to resolve this?
Adding docs is good.
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-debuggingThis PR adds a chrome option to enable these flags easily -
enable_webextensionsUser can either use the above chrome option or add the flags manually.
The
webExtension.installmethod 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_webextensionsoption to Chrome for BiDi webextensionsImproves error handling in
webExtension.installfor 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 optionspy/selenium/webdriver/chrome/options.py
enable_webextensionsproperty with getter/settersupport
webextension.py
Improve error handling for Chrome webextension installpy/selenium/webdriver/common/bidi/webextension.py
bidi_webextension_tests.py
Update and document BiDi webextension test for Chromepy/test/selenium/webdriver/common/bidi_webextension_tests.py
conftest.py
Enable Chrome webextensions in BiDi test configurationpy/conftest.py