-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
Allow Ferrum to use extensions? #61
Comments
Hey, unfortunately it's Chrome limitation and there's nothing Ferrum can do here. In headless mode they are all turned off, in headful mode they should work though I didn't test it. |
It's not working, that's the problem. Here I've disabled headless mode. Then the 2nd where the visit happens. It opens a new window in chrome where it's incognito |
I didn't try to load any extension now, but usually, incognito no extension is enabled. Is there a way to just control the first window? |
You should play around with Chrome flags https://github.com/rubycdp/ferrum/blob/master/lib/ferrum/browser/chrome.rb#L63 set the Profile folder, create one common context for all pages or the default one and then use it for all of them. |
All good? Did you manage to solve it? I see what you mean. I'll try to investigate it. |
It's Chrome's limitation, if you run Ferrum with browser = Ferrum::Browser.new(headless: false)
context_params = browser.command("Target.getBrowserContexts")["targetInfos"].select { |c| c["type"] == "page" }.first
context = Context.new(browser, browser.contexts, context_params["browserContextId"]) but unfortunately you won't be able to create pages inside this context: context.create_page
Traceback (most recent call last):
16: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
15: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/exe/bundle:30:in `block in <top (required)>'
14: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:18:in `start'
13: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
12: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:27:in `dispatch'
11: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
10: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
9: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
8: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:496:in `console'
7: from /home/route/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/console.rb:19:in `run'
6: from (irb):30
5: from /home/route/Projects/Ruby/ferrum/lib/ferrum/context.rb:41:in `create_page'
4: from /home/route/Projects/Ruby/ferrum/lib/ferrum/context.rb:45:in `create_target'
3: from /home/route/Projects/Ruby/ferrum/lib/ferrum/browser.rb:83:in `command'
2: from /home/route/Projects/Ruby/ferrum/lib/ferrum/browser/client.rb:48:in `command'
1: from /home/route/Projects/Ruby/ferrum/lib/ferrum/browser/client.rb:90:in `raise_browser_error'
Ferrum::BrowserError (Failed to find browser context with id D2FDBFAC3A0AE8F6826B778A5DA94968) Though you are able to get current target and visit given url: target_params = browser.command("Target.getTargetInfo", targetId: context_params["targetId"])["targetInfo"]
target = Target.new(browser, target_params)
target.page.goto("http://github.com") so it's only one page per visible window, you can only create pages in new contexts. |
I could load it. But no luck with controlling the extension. you know. I've tried your solution, but I get it as nil |
Then Chrome doesn't allow this I think |
I was also wondering why there are always two windows. One "regular" one and an Incognito one. Maybe it is because incognito mode usually restricts the usage of extensions? And just to clarify this: Puppeteer is also using CDP and explicitly mentions that it is indeed possible to use extensions in non-headless mode. By adding |
@alexanderadam I tried to use extension in the past to workaround proxy limits in headless chrome and this flag in particular didn't work. It only worked in headful mode. Things might have changed though I I didn't check it because Chrome dev team clearly stated in the past that extensions are not allowed. |
This is what I wrote (it is indeed possible to use extensions in non-headless mode.). 😉 |
Yea headful mode allows it. Sorry I missed it too many switches between tasks lol) |
Hey, currently It doesn't work to add extensions(Use them I mean)
I've tried to run it without headless enabled and they do really load.
But they load only in the initial window, the ferrum provided tabs don't have access to them :/
The text was updated successfully, but these errors were encountered: