简体   繁体   English

错误“org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/” with GeckoDriver 和 Firefox

[英]error“ org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/” with GeckoDriver and Firefox

Hello i can't test my junit this my error when i try to compile if someone can help me thank you你好,我无法测试我的 junit 这是我尝试编译时的错误,如果有人可以帮助我,谢谢

org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:18218 Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z' System info: host: 'UTILISA-3AHNTLM', ip: '10.2.10.137', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191' Driver info: driver.version: FirefoxDriver org.openqa.selenium.WebDriverException:java.net.ConnectException:无法连接到 localhost/0:0:0:0:0:0:0:1:18218 构建信息:版本:'3.14.0',修订: 'aacccce0',时间:'2018-08-02T20:05:20.749Z' 系统信息:主机:'UTILISA-3AHNTLM',ip:'10.2.10.137',os.name:'Windows 10',os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191' 驱动信息: driver.version: FirefoxDriver

Here is code for your reference: Note : It works fine on mac when i build with Junit这是供您参考的代码:注意:当我使用 Junit 构建时,它在 mac 上运行良好

package ca.qc.grasset_420_pa4_ag.lab05.authentification;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import ca.qc.grasset._420_pa4_ag.lab05.commons.AbstractFunctionalTest;

public final class InvalidUsernameLoginTest

    extends AbstractFunctionalTest {

    public InvalidUsernameLoginTest() {

        super();
    }

    @Test
    public void test() {

        getDriver().get("https://the-internet.herokuapp.com/");
        getDriver().findElement(By.linkText("Form Authentication"))
            .click();
        getDriver().findElement(By.id("username"))
            .click();
        getDriver().findElement(By.id("username"))
            .clear();
        getDriver().findElement(By.id("username"))
            .sendKeys("fdjkfgjkgfhkgf");
        getDriver().findElement(By.id("password"))
            .click();
        getDriver().findElement(By.id("password"))
            .clear();
        getDriver().findElement(By.id("password"))
            .sendKeys("SuperSecretPassword!");
        getDriver().findElement(
            By.xpath(
                "(.//*[normalize-space(text()) and normalize-space(.)='Password'])[1]/following::button[1]"))
            .click();
        validate();
    }

    @Override
    protected void validate() {

        WebElement element = getDriver().findElement(By.xpath("//*[@id=\"flash\"]"));

        String actualMessage = element.getText();
        Assert.assertTrue("Your username is invalid!\n×".equals(actualMessage));
    }
}

This error message...这个错误信息...

org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:18218

...implies that the ConnectException was raised while initializing the WebDriver session. ...暗示在初始化WebDriver会话时引发了ConnectException


Solution解决方案

Some more information regarding the binaries you are using might have been helpful to debug this issue which are as follows:有关您正在使用的二进制文件的更多信息可能有助于调试此问题,如下所示:

  • Your GeckoDriver version.您的GeckoDriver版本。
  • Your Firefox version.您的Firefox版本。

Some of the potential solutions to your issue are:您的问题的一些潜在解决方案是:

  • Ensure that /etc/hosts on your system contains the following entry:确保系统上的/etc/hosts包含以下条目:

     127.0.0.1 localhost.localdomain localhost #or 127.0.0.1 localhost loopback
  • Ensure the GeckoDriver-Firefox Mapping确保 GeckoDriver-Firefox 映射

Geckodriver 发布

  • Upgrade GeckoDriver to GeckoDriver v0.23.0 level.升级GeckoDriverGeckoDriver v0.23.0水平。
  • Ensure GeckoDriver is present in the specified location.确保GeckoDriver存在于指定位置。
  • Ensure GeckoDriver is having executable permission for non-root users.确保GeckoDriver对非 root 用户具有可执行权限。
  • Upgrade Firefox version to Firefox v62.0 levels.Firefox版本升级到Firefox v62.0级别。
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.通过IDE清理项目工作区并仅使用所需的依赖项重建项目。
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client .如果您的基本Web Client版本太旧,请通过Revo Uninstaller卸载它并安装最新的 GA 和发布版本的Web Client
  • Take a System Reboot .进行系统重启
  • Execute your Test as a non-root user.以非 root 用户身份执行您的Test

The answer of Wojciech-Kopec helps me solve this issue, that maybe u not install Microsoft Visual Studio redistributable yet Wojciech-Kopec回答帮助我解决了这个问题,也许你还没有安装Microsoft Visual Studio 可再发行组件

Try to download and install the appropriate .exe file here尝试在此处下载并安装相应的 .exe 文件

Hope this helps!希望这可以帮助!

暂无
暂无

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

相关问题 org.openqa.selenium.WebDriverException: java.net.ConnectException: 无法使用 GeckoDriver Firefox 和 Selenium 连接到 localhost/0:0:0:0:0:0:0 - org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0 using GeckoDriver Firefox and Selenium org.openqa.selenium.WebDriverException: java.net.ConnectException: 无法使用 GeckoDriver 和 Selenium 连接到 localhost/0:0:0:0:0:0:0:1:1941 - org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:1941 with GeckoDriver and Selenium org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost error with IEDriverServer - org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost error with IEDriverServer org.openqa.selenium.WebDriverException:java.net.ConnectException:使用Gecko驱动程序无法连接到本地主机 - org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost with Gecko driver org.openqa.selenium.WebDriverException:java.net.ConnectException,我该如何解决 - org.openqa.selenium.WebDriverException: java.net.ConnectException , HOW CAN i RESOLVE WebDriverException:java.net.ConnectException:无法在MacOS上使用Selenium 3和chromedriver连接到localhost错误 - WebDriverException: java.net.ConnectException: Failed to connect to localhost error with Selenium 3 and chromedriver on MacOS org.openqa.selenium.WebDriverException:[异常…“组件未初始化”错误使用 GeckoDriver 和 Tor 浏览器与 Selenium ZD52387880E1EA22817A7Z2D3759213891 - org.openqa.selenium.WebDriverException: [Exception… “Component not initialized” error using GeckoDriver and Tor browser with 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 树莓派 2 B + Selenium Java = WebDriverException: java.net.ConnectException: 连接失败 - Raspberry pi 2 B + Selenium Java = WebDriverException: java.net.ConnectException: Failed to connect 线程“main” org.openqa.selenium.WebDriverException 中的异常:在 geckodriver 升级后等待 45 秒让 Firefox 启动超时 - Exception in thread “main” org.openqa.selenium.WebDriverException: Timed out waiting 45 seconds for Firefox to start after geckodriver upgradation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM