Unable to connect to the electron / CEF app using selenium web driver

后端 未结 2 1246
星月不相逢
星月不相逢 2020-12-12 06:23

I am trying to automate [electron-api-demos][1]app using this sample code.

  public static void main(String args[]) throws IOException, InterruptedException          


        
2条回答
  •  离开以前
    2020-12-12 06:58

    @DebanjanB, Thanks for the help. After I changed the version of the selenium to alpha , I am able to connect to the app with out errors. I am using the following code now :

    public static void main(String args[]) throws IOException, InterruptedException {
            int port = 9223;
            // Open App
    
            Runtime.getRuntime().exec(
                    "C:\\Program Files\\SampleApp.exe", null,
                    new File("C:\\Program Files\\SampleApp"));
    
            ChromeOptions options = new ChromeOptions();
            String remoteDebuggingAddress = "localhost:" + port;
            options.setExperimentalOption("debuggerAddress", remoteDebuggingAddress);
            options.addArguments("remote-debugging-port=9223");
            options.setBinary(
                    "C:\\Program Files\\SampleApp.exe");
    
            System.setProperty("webdriver.chrome.driver",
                    "C:\\Users\\xyz\\eclipse-workspace\\xyz\\src\\demo1\\chromedriver.exe");
            WebDriver driver = new ChromeDriver(options);
            System.out.println(driver.getTitle());
    
        }
    

    The issue is I am not able to access the elements in chromium at http://localhost:9223/ When I open the chromium or chrome browser at teh local host the following text is displayed . Normally a link is expected . Link or the WebElements are not displayed.

    Inspectable WebContents scannerui/appfiles/index.html

提交回复
热议问题