Selenium Web Driver with user-data-dir set to crash in Chrome headless mode

profile_dir =  File.expand_path("profile",__dir__).encode("UTF-8")

U_d_Dir = "--user-data-dir=" + profile_dir
options = Selenium::WebDriver::Chrome::Options.new(args: ["--headless" ,'--no-sandbox', U_d_Dir])
driver = Selenium::WebDriver.for :chrome, options: options

reference [Unresolved] Chrome headless mode cannot be used with Selenium Web Driver for which user-data-dir is set. https://teratail.com/questions/142395 Error occurs when headless and user-data-dir options are specified at the same time in chromedriver https://ja.stackoverflow.com/questions/51441/chromedriver-%E3%81%A7-headless-%E3%81%A8-user-data-dir-%E3%81%AE%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E5%90%8C%E6%99%82%E3%81%AB%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8B%E3%81%A8%E3%82%A8%E3%83%A9%E3%83%BC%E3%81%8C%E7%99%BA%E7%94%9F%E3%81%99%E3%82%8B

Recommended Posts

Selenium Web Driver with user-data-dir set to crash in Chrome headless mode
[Java] A quick introduction to integration testing with Selenide + Chrome Driver <Updated in May 2020>
Change driver to Rack :: Test if driver wants to POST in Selenium test
How to set up a proxy with authentication in Feign