lundi 12 avril 2021

Add settings to driver in selenium

Hi I am trying to add some settings to my driver in selenium but can seem to make them work.

Im trying to add

{ 
 "DEVELOPER_MODE":false,
 "AUTOMATION_MODE":true,
 "AUTOMATION_LAUNCH_URL":"{whatever_url_you_want_to_test_with}"
}

to my driver file

     public static WebDriver startDriverTwo() {
        String projectLocation = System.getProperty("user.dir");
        System.setProperty("webdriver.chrome.driver", projectLocation + "/chromedriver.exe");
       

        ChromeOptions opt = new ChromeOptions();
        opt.addArguments("start-maximized");
        opt.addArguments("disable-infobars");
        opt.addArguments("--disable-extensions");
        opt.addArguments("--window-size=1920x1080");
        opt.addArguments("--disable-cache");
        //options.addArguments("--headless");
        opt.addArguments("--disable-application-cache");
        opt.addArguments("--disk-cache-size=0");
        opt.addArguments("--disable-gpu"); // applicable to windows os only
        opt.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
        opt.addArguments("--dns-prefetch-disable");
        opt.addArguments("--disable-notifications");
        opt.addArguments("disable-infobars")

        //Enter the path of your Electron app
        opt.setBinary("pathtoelectronapp.exe");
        driver = new ChromeDriver(opt);
        System.out.println("opening app");
        return driver;


    }

I have tried

setExperimentalOption()
setProperty()

But neither of these work? any idea how i can work these in?

Aucun commentaire:

Enregistrer un commentaire