【发布时间】: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());
}
【问题讨论】:
-
我尝试了这个解决方案,但它不起作用
-
这不是错误,这是 Chrome 驱动程序的第一行日志记录。之后添加可能包含错误的行。应该是版本问题。验证最新的 chromedriver.exe
-
我正在使用 chromedriver 2.25 最新版本的 Google chrome 54
标签: java eclipse google-chrome selenium junit