0

獲取下面的錯誤運行硒試圖執行硒Firefox的驅動程序我的本地URL時:嗨即時得到下面的錯誤,當我嘗試通過Eclipse進行我的本地URL測試

INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end 
org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Detected dialect: W3C 
ession ID: 107f76f0-251f-4d62-9308-2968ed6e354f 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163) 
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) 
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322) 
    at Gmail_login.main(Gmail_login.java:14) 

代碼

import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.By; 
public class Gmail_login { 

    public static void main(String[] args) { 
     // TODO Auto-generated method stub 
    // objects and variables instantiation 
      System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe"); 
      WebDriver driver = new FirefoxDriver(); 
      String appUrl = "https://localhost/qwer"; 
    // launch the firefox browser and open the application url 
      driver.get(appUrl); 
    //maximize the browser window 
      driver.manage().window().maximize(); 
    //declare and initialize the variable to store the expected title of the webpage. 
      String expectedTitle = "Web Login Service"; 
    //fetch the title of the web page and save it into a string variable 
      String actualTitle = driver.getTitle(); 
    //compare the expected title of the page with the actual title of the page and print the result 
      if (expectedTitle.equals(actualTitle)) 
      { 
       System.out.println("Verification Successful - The correct title is displayed on the web page."); 
      } 
      else 
      { 
      System.out.println("Verification Failed - An incorrect title is displayed on the web page."); 
      } 
    // enter a valid username in the email textbox 
      WebElement username = driver.findElement(By.id("username")); 
      username.clear(); 
      username.sendKeys("[email protected]"); 
       // enter a valid password in the password textbox 
      WebElement password = driver.findElement(By.id("password")); 
      password.clear(); 
      password.sendKeys("Welcome"); 
       // click on the Sign in button 
      WebElement SignInButton = driver.findElement(By.name("_eventId_proceed")); 
      SignInButton.click(); 
       // close the web browser 
      driver.close(); 
      System.out.println("Test script executed successfully."); 
        // terminate the program 
      System.exit(0); 

    } 

} 
+0

請讓我知道我即將獲得上述錯誤。這對像我這樣的初學者會非常有幫助。謝謝。 – Karthikbalaji

回答

1

如果url無法訪問,Firefox驅動程序會拋出此錯誤,例如無法解析域名或服務器塊連接。如果您在本地主機上安裝了網絡服務器併爲該網址提供了一些內容,它將起作用。 您可以嘗試將firefox切換到不會針對此方案拋出異常的Chrome。您也可以在您的driver.get()聲明中編寫try-catch塊。

0

這是一條INFO消息,只是讓人們可以看到發生了什麼。它不是一個錯誤,也不需要擔心。

該消息使用的版本時上述selenium3.0.0和geckodriver

這將不會停止腳本執行發生。

相關問題