亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

錯誤“org.openqa.selenium.WebDriverException:

錯誤“org.openqa.selenium.WebDriverException:

慕虎7371278 2021-12-22 20:37:45
您好,我無法測試我的 junit 這是我嘗試編譯時的錯誤,如果有人可以幫助我,謝謝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這是供您參考的代碼:注意:當我使用 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));    }}
查看完整描述

2 回答

?
慕碼人8056858

TA貢獻1803條經驗 獲得超6個贊

這個錯誤信息...


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

...暗示在初始化WebDriver會話時引發了ConnectException。


解決方案

有關您正在使用的二進制文件的更多信息可能有助于調試此問題,如下所示:


您的GeckoDriver版本。

您的Firefox版本。

您的問題的一些潛在解決方案是:


確保/etc/hosts您的系統上包含以下條目:


127.0.0.1 localhost.localdomain localhost

#or

127.0.0.1 localhost loopback

確保 GeckoDriver-Firefox 映射

http://img1.sycdn.imooc.com//61c31c3a0001e08205450349.jpg

  • 升級GeckoDriverGeckoDriver v0.23.0水平。

  • 確保GeckoDriver存在于指定位置。

  • 確保GeckoDriver對非 root 用戶具有可執行權限。

  • Firefox版本升級到Firefox v62.0級別。

  • 清理你的項目工作,通過你的IDE重建僅需要依賴你的項目。

  • 如果您的基本Web Client版本太舊,請通過Revo Uninstaller卸載它并安裝最新的 GA 和發布版本的Web Client。

  • 進行系統重啟。

  • Test以非 root 用戶身份執行您的操作。


查看完整回答
反對 回復 2021-12-22
?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

沃伊切赫- Kopec先生的回答可以幫助我解決這個問題,那也許ü沒有安裝 微軟的Visual Studio再分發尚未

嘗試在此處下載并安裝相應的 .exe 文件

希望這可以幫助!


查看完整回答
反對 回復 2021-12-22
  • 2 回答
  • 0 關注
  • 1355 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號