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

Remove browser_options in DEFAULT_OPTIONS #67

Closed
peter50216 opened this issue Apr 16, 2020 · 5 comments
Closed

Remove browser_options in DEFAULT_OPTIONS #67

peter50216 opened this issue Apr 16, 2020 · 5 comments

Comments

@peter50216
Copy link

Currently the DEFAULT_OPTIONS in lib/ferrum/browser/chrome.rb can't be removed by the options given to Ferrum::Browser.new. Is there any way to do that?

The problem I'm facing is that some website check the "origin" HTTP header on the server side, and with "--disable-web-security" Chrome doesn't send the origin header at all.

Workaround I'm using now is:

opt = Ferrum::Browser::Chrome.send(:remove_const, :DEFAULT_OPTIONS).dup
opt.delete('disable-web-security')
Ferrum::Browser::Chrome.const_set(:DEFAULT_OPTIONS, opt)
@sebyx07
Copy link
Contributor

sebyx07 commented Apr 17, 2020

I've also encountered this problem. Had to override the constant

@route
Copy link
Member

route commented Apr 18, 2020

Sounds like we need a way not to apply default options, I'll try to solve it

@Mifrill
Copy link
Collaborator

Mifrill commented Apr 19, 2020

from my perspective, we, probably, can allow to manage disable-web-security flag as same as headless, it's looks like good enough solution here. #70

way not to apply default options

if you think so, we can, probably, proceed with the approach, like: allow to set any of default_browser_options without our DEFAULT_OPTIONS #71

@peter50216 , @sebyx07 , @route WDYT?

@sebyx07
Copy link
Contributor

sebyx07 commented Apr 19, 2020

smth like

Ferrum::Browser.new(browser_options: Ferrum::Browser::ChromeOptions.except('disable-web-security').merge({'load-extension' = nil})

so if you don't need advanced stuff you will just browser_options: Ferrum::Browser::ChromeOptions

Ferrum::Browser::ChromeOptions.except / Ferrum::Browser::ChromeOptions.merge return a new hash with the existing options

@route route closed this as completed in 96456ea May 31, 2020
@route
Copy link
Member

route commented May 31, 2020

96456ea#diff-f5498ea1e75e533f906aaa25b2e97ddeR48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants