简体   繁体   English

org.openqa.selenium.remote.UnreachableBrowserException如何定义EXE路径?

[英]org.openqa.selenium.remote.UnreachableBrowserException How to define EXE path?

I have this java class code in package ChromeBrowser (That I made) 我在ChromeBrowser包中有这个Java类代码(我做了)

package ChromeBrowser;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class LaunchChrome{

    public static void main(String[] args){
        String url = "<<<The URL I want to open>>>";
        WebDriver driver = setUp();
        launch(driver, url);
    }
    static void launch(WebDriver driver, String url) {
        driver.navigate().to(url);
    }
    static WebDriver setUp() {
        System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
        WebDriver driver=new ChromeDriver();
        return driver;
    }
}

But when I run it, I get the error: 但是当我运行它时,我得到了错误:

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

Steps I've taken: 我已采取的步骤:

  • I have chrome installed. 我已安装Chrome。
  • I have downloaded the webdriver, and checked it is in C:\\Selenium\\chromedriver.exe 我已经下载了webdriver,并检查它是否在C:\\ Selenium \\ chromedriver.exe中
  • java jdk is in environment path java jdk在环境路径中
  • webdriver is in environment path, added in attempt to solve, didnt work webdriver在环境路径中,试图解决时添加了它,但没有起作用
  • The code compiles and runs on my colleague's machine 该代码在我同事的机器上编译并运行
  • Expected result: 预期结果:

  • Chrome browser opens at The URL I want to open. Chrome浏览器在我要打开的URL处打开。

    Do I need to define the path to the chrome executable at C:\\Program Files (x86)\\Google\\Chrome\\Application? 我是否需要在C:\\ Program Files(x86)\\ Google \\ Chrome \\ Application下定义chrome可执行文件的路径?

    Help me please thanks in advance. 请帮助我,谢谢。

    EDIT:: I've tried most of the other stack overflow questions with the name of the error, but they haven't helped. 编辑::我已经尝试了其他大多数使用错误名称的堆栈溢出问题,但它们并没有帮助。

  • I am not really sure what the issue is but you can try below suggestions- 我不太确定问题是什么,但是您可以尝试以下建议-

    1. System.setProperty("webdriver.chrome.driver", "C:/Selenium/chromedriver.exe"); System.setProperty(“ webdriver.chrome.driver”,“ C:/Selenium/chromedriver.exe”);

    2. This could be a compatibility issue between the 'selenium', 'Chrome browser version' and 'chrome driver' version that you are using. 这可能是您使用的“硒”,“ Chrome浏览器版本”和“ chrome驱动程序”版本之间的兼容性问题。 If you are using Selenium 2.53, then using chrome driver 2.25 should work for you. 如果您使用的是Selenium 2.53,则应使用chrome驱动程序2.25。

    3. Download latest chrome driver from seleniumhq.org 从seleniumhq.org下载最新的Chrome驱动程序

    4. Add 127.0.0.1 localhost to C:\\Windows\\System32\\drivers\\etc\\hosts. 将127.0.0.1本地主机添加到C:\\ Windows \\ System32 \\ drivers \\ etc \\ hosts。

    Seems like there is some issue with creating session with Firefox. 似乎使用Firefox创建会话存在一些问题。 Try the following code and test using Chrome browser. 尝试以下代码,然后使用Chrome浏览器进行测试。

    You need to download the executable driver from: https://sites.google.com/a/chromium.org/chromedriver/downloads 您需要从以下位置下载可执行驱动程序: https : //sites.google.com/a/chromium.org/chromedriver/downloads

    public static void main(String[] args){
    System.setProperty("webdriver.chrome.driver",
    "/path/to/chromedriver");
    WebDriver driver = new ChromeDriver();
    driver = new ChromeDriver();
    //Puts an Implicit wait, Will wait for 10 seconds before throwing exception
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    
    //Launch website
    driver.get("http://www.calculator.net/");
    
    //Maximize the browser
    driver.manage().window().maximize();
    

    or Check the network settings (proxy, firewall, antivirus software), something is blocking connections between selenium and the browser. 或检查网络设置(代理,防火墙,防病毒软件),发现某些东西阻止了硒与浏览器之间的连接。

    暂无
    暂无

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

    相关问题 org.openqa.selenium.remote.UnreachableBrowserException: - org.openqa.selenium.remote.UnreachableBrowserException: org.openqa.selenium.remote.UnreachableBrowserException - org.openqa.selenium.remote.UnreachableBrowserException 线程“主”中的Selenium异常org.openqa.selenium.remote.UnreachableBrowserException - Selenium Exception in thread “main” org.openqa.selenium.remote.UnreachableBrowserException 硒 Java org.openqa.selenium.remote.UnreachableBrowserException - Selenium Java org.openqa.selenium.remote.UnreachableBrowserException org.openqa.selenium.remote.UnreachableBrowserException:与远程浏览器通信时出错 - org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser selenium exceptionin java(org.openqa.selenium.remote.UnreachableBrowserException) - selenium exceptionin java (org.openqa.selenium.remote.UnreachableBrowserException) org.openqa.selenium.remote.UnreachableBrowserException:-错误的硒Java TestNG - org.openqa.selenium.remote.UnreachableBrowserException: - Error selenium Java TestNG 线程“主” org.openqa.selenium.remote.UnreachableBrowserException中的异常: - Exception in thread “main” org.openqa.selenium.remote.UnreachableBrowserException: org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话 - org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session org.openqa.selenium.remote.UnreachableBrowserException与远程浏览器幻象js通信时出错 - org.openqa.selenium.remote.UnreachableBrowserException Error communicating with the remote browser phantom js
     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM