jeudi 1 avril 2021

Cant interact with Elements in electron app using selenium

Im trying to runs tests on my Electron App but I cant seem to interact with any of the elements on the page. My driver looks like this:

        public static ChromeDriver startDriverTwo() {
        String projectLocation = System.getProperty("user.dir");

        ChromeOptions opt = new ChromeOptions();
        //Enter the path of your Electron app
        opt.setBinary("C:/path/to/app.exe");
        
        System.setProperty("webdriver.chrome.driver", projectLocation + "/chromedriver.exe");

        driver = new ChromeDriver(opt);

        return driver;
    }

I then launch a url but it doesnt seem to pick up any of the elements on said page. Im using

public class PageFactory {
public PageFactory() {
}

public static <T> T initElements(WebDriver driver, Class<T> pageClassToProxy) {
    T page = instantiatePage(driver, pageClassToProxy);
    initElements(driver, page);
    return page;
}

and

private static void initAllPages() { // Add EACH ONE of the pages to be initiated here, regardless of 
which section they may be coming from, otherwise a Null Pointer Exception may occur
    PageFactory.initElements(driver, InitPages.class);

}

to avoid Null Pointer exceptions

Aucun commentaire:

Enregistrer un commentaire