Chrome会打开"数据;"地址与硒

时间:2016-12-10 16:15:27

标签: java google-chrome selenium chrome-web-driver

当我开始测试时,我会看到'数据:,'在chrome地址栏中然后没有任何反应(程序不会继续)而不是开始导航到url。 我正在使用:chrome = 55.0.2883.75 chromedriver = 2.25 selenium = 3.0.1 platform = Win64

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import static org.junit.Assert.assertEquals;

public class MyClass {

    public static void main(String[] args) {
        WebDriver driver;
        System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver_win32\\chromedriver.exe");
        driver = new ChromeDriver ();
        driver.get("http://www.google.com");
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.xpath("//*[@id='lst-ib']")).sendKeys("facebook");
        driver.findElement(By.cssSelector("input[name='btnK']")).click();
        driver.findElement(By.linkText("Facebook - Log In or Sign Up")).click();

        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        WebDriverWait wait = new WebDriverWait(driver, 10);
        wait.until(ExpectedConditions.elementToBeClickable(By.id("u_0_n")));

        String expectedTitle = "Facebook - Log In or Sign Up";

        assertEquals(expectedTitle,driver.getTitle());

        driver.quit();
    }
}

1 个答案:

答案 0 :(得分:1)

尝试使用新的ChromeDriver exe(2.26)。下载here。你可以在notes中看到2.25假设支持Chrome 55但是有错误修复,所以请尝试最新的。