0

My browser-based application has recently switched over to an electron app and now the tests obviously don't seem to work, they can't pick up the windows and the elements correctly.

I've read that Spectron is used to test electron apps but is it possible to use it with Java and Selenium? I haven't been able to find any examples that aren't in Js. Are there any examples of how electron can be used with java?

Currently, I'm running my electron app like this

 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");
      
        //Enter the path of your Electron app
        opt.setBinary("C:/path/to/app.exe");
        opt.addArguments("start-maximized");
        //opt.addArguments("--headless");


        driver = new ChromeDriver(opt);

        return driver;
    }
       

And then I get(Url), but this opens 2 windows, and selenium can't seem to recognize them.

FearghalQA
  • 255
  • 1
  • 2
  • 11
  • Is your electron app a desktop app? If so, then you can't use selenium – Lia Apr 08 '21 at 13:29
  • Yep its a desktop app, the thing is I have 1000 test cases already that will be wasted other wise, what tools have you used for this that have worked the best? – FearghalQA Apr 08 '21 at 13:41
  • Sorry, but you can't use Selenium for desktop app testing. If your tests have a good layer of abstraction you still can use them but change all your selenium related code. Can't recommend any tool as it's opinion based, take a search for Desktop Application testing tools – Lia Apr 08 '21 at 14:56
  • Ive managed to get it working using chrome driver over the app – FearghalQA Apr 08 '21 at 15:11
  • Take a look at that thread https://sqa.stackexchange.com/questions/9254/can-i-use-selenium-to-do-desktop-application-testing – Lia Apr 08 '21 at 15:24

0 Answers0