0

To preface, I cannot run in --headless mode because I unfortunately need to get a file to download, and using ChromeDriver without --headless is the only way I can get it to work. The script runs fine manually, and also runs fine when scheduled and logged in, but it failed when scheduled and the screen was locked/user logged out.

I ideally want this to be able to run while logged out but still have access to the default ChromeDriver behavior that exists when I'm logged in/unlocked. I have a bad feeling this isn't possible because it seems as though the non-headless version depends on a graphics input, but I'm hoping I'm wrong. Again, the file download is the main constraint here, otherwise I would just use HTMLUnitDriver.

Here is my driver configuration for reference:

    //browser prefs
    HashMap<String, Object> preferences = new HashMap<>();
    preferences.put("profile.default_content_settings.popups", 0);
    preferences.put("download.default_directory", downloadPath);

    //browser options config
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", preferences);

    DesiredCapabilities cap = DesiredCapabilities.chrome();
    cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    cap.setCapability(ChromeOptions.CAPABILITY, options);

    //add capabilities to options
    options.merge(cap);

    WebDriver driver = new ChromeDriver(options);

I'm using the newest version of chromedriver.exe.

Trevor Bye
  • 686
  • 1
  • 6
  • 26
  • Selenium definitely does not rely on visual environment to run. This is a normal practice to run test on headless machines, In your case you likely have some issue with user permissions. Can you please clarify whether you get errors or it is not being triggered at all? – Eugene S Jan 15 '18 at 03:07
  • It's being triggered, and when logged out it throws a `Launch Failure`. But like I said it runs fine when logged in, and I have the password entered for the account to run while logged out. Just to clarify, I am not running `ChromeDriver` in headless mode, because if I do I can't fetch the download. – Trevor Bye Jan 16 '18 at 15:53

1 Answers1

0

I think, that the point is, that you try to run test when you not loggged in on windows. Maybe you should create server for automatic tests. Stable and without costs will be server on linux. You can launch without x-wing - more in (this if for firefox, but you can just change driver to chromedriver and all will works fine) Is it possible to run selenium (Firefox) web driver without a GUI?