简体   繁体   English

org.openqa.selenium.WebDriverException:未知错误:.net::ERR_CONNECTION_REFUSED

[英]org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED

When I try to run my project using Selenium and Java, I am getting this error and I do not know how to solve it.当我尝试使用 Selenium 和 Java 运行我的项目时,出现此错误并且我不知道如何解决。 This is happening on VSCode and the SO is Windows 11.这发生在 VSCode 上,SO 是 Windows 11。

org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: chrome=108.0.5359.125)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

This is the code I created:这是我创建的代码:

WebDriver browser = new ChromeDriver();
browser.navigate().to("http://localhost:8080/leiloes");
browser.quit();

I appreciate your help.我感谢您的帮助。

Marcelo马塞洛

You need to set the property of webdriver like below, and you can use get instead of driver.get("http://www.facebook.com");你需要像下面这样设置webdriver的属性,你可以使用get而不是driver.get("http://www.facebook.com");

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class TestChrome {

    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");

        // Initialize browser
        WebDriver driver = new ChromeDriver();

        // Open facebook
        driver.get("http://www.facebook.com");

        // Maximize browser

        driver.manage().window().maximize();

    }

}

暂无
暂无

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

相关问题 如何修复org.openqa.selenium.WebDriverException:未知错误 - How to fix the org.openqa.selenium.WebDriverException: unknown error org.openqa.selenium.WebDriverException:未知错误:.net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH 在 MAC 上使用 Selenium 启动 Brave 浏览器时出错 - org.openqa.selenium.WebDriverException: unknown error: net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH error initiating Brave browser using Selenium on MAC org.openqa.selenium.WebDriverException:使用Selenium Java和Webdriver时连接被拒绝(Linux头没有Xvfb) - org.openqa.selenium.WebDriverException: connection refused while using Selenium Java and webdriver (linux headless with Xvfb) Selenium switchTo返回错误org.openqa.selenium.WebDriverException:未知错误:无法确定加载状态 - Selenium switchTo return error org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status org.openqa.selenium.WebDriverException:未知错误:无法使用ChromeDriver Selenium和Java聚焦元素 - org.openqa.selenium.WebDriverException: unknown error: cannot focus element using ChromeDriver Selenium and Java org.openqa.selenium.WebDriverException:未知错误:无法通过Java用ChromeDriver Chrome和Selenium集中元素 - org.openqa.selenium.WebDriverException: unknown error: cannot focus element with ChromeDriver Chrome and Selenium through Java 线程“主”org.openqa.selenium.WebDriverException 中的异常:未知错误:使用 Selenium Java 的意外命令响应 - Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unexpected command response using Selenium Java org.openqa.selenium.WebDriverException:未知错误:chrome 无法通过 Java 开始使用 Selenium ChromeDriver 和 Chrome - org.openqa.selenium.WebDriverException: unknown error: chrome failed to start using Selenium ChromeDriver and Chrome through Java 获取错误:org.openqa.selenium.WebDriverException:未知错误:密钥应为字符串 - Getting error : org.openqa.selenium.WebDriverException: unknown error: keys should be a string 线程“ main” org.openqa.selenium.WebDriverException中的异常:未知错误:Chrome无法启动:正常退出 - Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM