Running ChromDriver on linux / unix Operating System using Jav
1. Download ChromeDriver for the linux environment
2. create a folder "drivers" on project folder
3. put the chromedriver file on the drivers folders
4. on the project class file copy the below script
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
Map prefs = new HashMap();
prefs.put("profile.default_zoom_level", -0.15);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("window-size=1920x1080"); // used to show webpage in standard window size
driver = new ChromeDriver(chromeOptions);
5. Imports
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
6. Few notes: FYI
You can run chromedriver on linux only in headless mode
When you automate something to do with downloading a file does not work in headless mode.
2. create a folder "drivers" on project folder
3. put the chromedriver file on the drivers folders
4. on the project class file copy the below script
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
Map
prefs.put("profile.default_zoom_level", -0.15);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("window-size=1920x1080"); // used to show webpage in standard window size
driver = new ChromeDriver(chromeOptions);
5. Imports
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
6. Few notes: FYI
You can run chromedriver on linux only in headless mode
When you automate something to do with downloading a file does not work in headless mode.
Comments
Post a Comment