2017-05-26 27 views
-1

登錄錯誤與下面的代碼登錄錯誤:與下面一塊代碼

System.setProperty("webdriver.gecko.driver", "C:\Users\Rocket\Downloads\setups\geckodriver.exe"); 
WebDriver driver = new FirefoxDriver(); 
driver.get("https://www.gmail.com");      
driver.findElement(By.xpath("//input[@type='email']")).sendKeys("[email protected]"); 
driver.findElement(By.xpath("//*[@id='identifierNext']/div[2]")).click(); 
driver.findElement(By.xpath("//input[@type='password']")).sendKeys("Ihate"); 
+1

你得到的錯誤是什麼?請詳細說明 – Alok

+0

@AnoopBhargava您能否考慮以下幾點:1.適當地設置代碼的格式以進行正確的分析。 2.提供相關的HTML DOM。 3.研究SO志願者提出的答案。 4.在問題區域更新您當前的代碼和錯誤堆棧跟蹤。謝謝 – DebanjanB

回答

0

你已經給了司機

System.setProperty(「‘’」路徑)應該有雙斜線,因爲Java將單斜槓作爲字符串中的轉義字符。它應該是 enter image description here

+0

功能[{moz:profile = C:\ Users \ Rocket \ AppData \ Local \ Temp \ rust_mozprofile.LfOKuZR3HcxN,rotate = false,timeouts = {implicit = 0.0,pageLoad = 300000.0,script = 30000.0}, –

0

這裏是回答你的問題:

當你指定System.setProperty就不得不提到的geckodriver無論是絕對路徑 - 逃離反斜槓

  • 如:

    System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe"); 
    

  • 使用正斜槓:

    System.setProperty("webdriver.gecko.driver", "C:/your_directory/geckodriver.exe"); 
    

    讓我知道如果這個回答你的問題。

+0

我的測試是運行並正在檢測壁虎驅動程序,但是當它移動到密碼時,它不會進入並給出錯誤的功能,例如:Capabilities [{moz:profile = C:\ Users \ Rocket \ AppData \ Local \ Temp \ rust_mozprofile.LfOKuZR3HcxN ,rotate = false,timeouts = {implicit = 0.0,pageLoad = 300000.0,script = 30000.0}, –

+0

@AnoopBhargava你能更新我的Selenium,geckodriver和Mozilla Firefox版嗎?謝謝 – DebanjanB

+0

geckodriver-v0.16.1-win64;硒 - java的3.4.0; firefox 53.0.3 –