【问题标题】:Google chrome with seleneium web driver带有硒网络驱动程序的谷歌浏览器
【发布时间】:2017-04-16 05:31:22
【问题描述】:

我正在尝试使用 Google Chrome 在 Eclipse 中运行 Selenium WebDriver,但是当我运行我的代码时出现此错误:

启动 ChromeDriver 2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed) 在端口 40315 上

只允许本地连接。

这是我的代码:

package Login; 

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class CorrectLogin {
  private WebDriver driver;
  private String baseUrl;
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

@Before
public void setUp() throws Exception {
  System.setProperty("webdriver.chrome.driver", "D://DownLoads//chromedriver.exe");
  WebDriver driver = new ChromeDriver();   
  baseUrl = "https://10.96.0.65:9443/";
  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void testFirstTestCase() throws Exception {
  driver.get(baseUrl + "POSAdminTool/AdminTool/Login.faces");
  driver.findElement(By.id("form1:passwordLabel")).clear();
  driver.findElement(By.id("form1:passwordLabel")).sendKeys("1234");
  driver.findElement(By.id("form1:usernameLabel")).clear();
  driver.findElement(By.id("form1:usernameLabel")).sendKeys("superuser");
  driver.findElement(By.id("form1:btn_login")).click();

  assertEquals("Search Account", driver.findElement(By.id("searchTitle")).getText());
}

【问题讨论】:

标签: java eclipse google-chrome selenium junit


【解决方案1】:
  1. 也许原因在闪光?

    System.setProperty("webdriver.chrome.driver", "bin/chromedriver.exe");

  2. 检查 - 此文件夹中有 chromedriver.exe 文件吗?
  3. 驱动程序 = 新的 ChromeDriver();试试看 - 我想这是一个主要原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多