lefthandedgoat / canopy

f# web automation and testing library, built on top of Selenium (friendly to c# also)
http://lefthandedgoat.github.io/canopy/
MIT License
505 stars 117 forks source link

Expose ChromeOptions #507

Closed fischgeek closed 3 years ago

fischgeek commented 3 years ago

Is your feature request related to a problem? Please describe. I've found myself in a position where I need to set some chrome options before execution. Specifically the "Download PDF files instead of automatically opening them in Chrome" option.

Describe the solution you'd like It would be really nice if this could be configurable prior to running the test.

Describe alternatives you've considered Right now, I navigate to the screen for the test by doing url chrome://settings/content/pdfDocuments?search=pdf and then prompting to turn it on before continuing. While this works okay, it's not fully automated.

Additional context If Selenium exposes more ChromeOptions I would like to see those available as well to optimize specific tests in the future. Mostly just focused on the pdf download option now.

lefthandedgoat commented 3 years ago

You can start a ChromeWithOptions to pass ChromeOption in.

https://github.com/lefthandedgoat/canopy/blob/master/src/canopy/canopy.parallell.functions.fs#L850

fischgeek commented 3 years ago

Sweet! I'm not quite up to speed on how to fully use Canopy outside of starter kit and demos I've read so not sure how to implement this. Not to mention what the specific chrome option is; I'll of course have to research that up a bit. Thank you!

lefthandedgoat commented 3 years ago

@fischgeek No problem! Dont forget the documentation, http://lefthandedgoat.github.io/canopy/

fischgeek commented 3 years ago

Haha! yes, thank you. The documentation page has been a bookmark bar button for the past week. I'm just trying to comb through it to find out how to set this up.

fischgeek commented 3 years ago

Found it! Thanks again!

This SO article helped as well.

let startMode = 
            let options = Chrome.ChromeOptions()
            options.AddUserProfilePreference("download.prompt_for_download", false)
            options.AddUserProfilePreference("plugins.plugins_disabled", "Chrome PDF Viewer")
            options.AddUserProfilePreference("plugins.always_open_pdf_externally", true)
            let start = canopy.types.BrowserStartMode.ChromeWithOptions options
            start

start startMode