2017-05-26 70 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 –