I'm able to run selenium on non GUI centos/linux machine in headless mode.
I have been trying to run it with cache enable by passing below chromeoptions arguments.
chromeOptions.addArguments("user-data-dir=~/.config/google-chrome");
It has started fine and identified elements till login page(which is first page) and couldn't identify any locators after that.
Is it the right approach to run cache enabled selenium run?
CodePudding user response:
It's not that super clear when you mention about executing your tests with cache enabled. However, adding the argument user-data-dir
is the canonical way to use a specific Chrome Profile.
You can find a couple of detailed discussions in:
- How to open a Chrome Profile through Python
- How to use Chrome Profile in Selenium Webdriver Python 3
CodePudding user response:
Adding those options helps me to prevent crashes and errors on a linux remote machine
ChromeOptions options = new ChromeOptions();
options.addArguments(
"--disable-gpu",
"--headless",
"--window-size=1920,1200",
"--ignore-certificate-errors",
"--disable-extensions",
"--no-sandbox",
"--disable-dev-shm-usage",
"--hide-scrollbars",
"--allow-running-insecure-content",
"--disable-infobars",
"--ignore-certificate-errors");
Webdriver driver = new ChromeDriver(options);