我正在尝试使用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());
}
答案 0 :(得分:0)
也许原因是闪光灯?
System.setProperty(“webdriver.chrome.driver”,“bin / chromedriver.exe”);