2016-12-10 34 views
1

當我開始測試時,我在chrome地址欄中看到'data :,',然後沒有任何反應(程序不會繼續),而不是開始導航到網址。 我使用:鉻= 55.0.2883.75 chromedriver = 2.25 =硒3.0.1平臺= 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

新ChromeDriver EXE(2.26)試試吧。下載here。您可以在notes中看到2.25假設支持Chrome 55,但有錯誤修復,因此請嘗試使用最新版本。

+0

謝謝它的作品! – moral17592

+0

不客氣!我正在爲這些案例研究[maven plugin](https://github.com/best-est/maven-web-drivers-compatibility-plugin)...我還有很多工作要完成正確... – Moshisho

+0

嗨,我使用相同的Chrome版本,以及ChromeDriver 2.26。嘗試執行webdriver.manage()。deleteAllCookies()將拋出以下異常:org.openqa.selenium.WebDriverException:未知錯誤:Runtime.executionContextCreated具有無效的「上下文」:{「auxData」:{「frameId」:「4064.1 」, 「ISDEFAULT」:真正}, 「ID」:1, 「名」: 「」, 「原產地」: 「://」}。 Chrome和ChromeDriver的舊版本引發了這種情況。有人有想法嗎? –