使用Maven运行selenium并获取未声明的 Headers

这是我正在使用的代码

public void SearchFor(final String searchKeyword)
{
    WebElement searchBox =  driver.findElement(By.name("q"));
    searchBox.sendKeys(searchKeyword);
    searchBox.submit();
    driver.findElement(By.name("btnG")).click();

    ExpectedCondition e = new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver webdriver) {
            return webdriver.getTitle().toLowerCase().startsWith(searchKeyword);
        }
    };

    new WebDriverWait(driver,10).until(e);
}

这是考验

@Test
public void TestThis()
{
    String searchWord = "Drupal!";
    homePage.SearchFor(searchWord);

    assertEquals("Drupal! - Google Search",homePage.GetTitle());

    homePage.CloseBrowser();
}

当我从maven(mvn clean test)运行这个时,我得到了这个错误

驱动程序信息:driver.version:未知org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259)org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228 )在com.testTickets.app.HomePage.SearchFor(HomePage.java:36)的com.testTickets.app.TestRunner.TestThis(TestRunner.java:17)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun . 在org.junit.runners的java.lang.reflect.Method.invoke(Method.java:483)的sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中的reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) .model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:47)org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod . java:44)org.junit.inun.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)at org.junit.runners.ParentRunner.runLeaf(ParentRunn) er.java:271)org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)org.junit.runners.ParentRunner $ 3 . 运行(ParentRunner.java:238)org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:63)org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)org.junit.runners . 在org.apache的org.junit.runners.ParentRunner.run(ParentRunner.java:309)org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:229)的ParentRunner.access $ 000(ParentRunner.java:53)位于org.apache.maven.surefire.junit4.JUnit4Provider的org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)中的.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) .invoke(JUnit4Provider.java:112)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.Deleg位于org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)的java.lang.reflect.Method.invoke(Method.java:483)atingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)位于org.apache.maven.surefire的org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)的.apache.maven.surefire.booter.ProviderFactory $ ProviderProxy.invoke(ProviderFactory.java:165) .booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)位于org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

如果我从IntelliJ IDE运行它,断言失败说它期望一个假并得到一个真 .

我一直试图在昨天和今天整天调试它,似乎无法理解为什么这不起作用 . 请帮忙

(更新:如果我将预期条件更改为预期条件,它将开始工作

public void SearchFor(final String searchKeyword)
{
    WebElement searchBox =  driver.findElement(By.name("q"));
    searchBox.sendKeys(searchKeyword);
    searchBox.submit();
    driver.findElement(By.name("btnG")).click();

    new WebDriverWait(driver,10).until(ExpectedConditions.titleContains(searchKeyword));
})

回答(0)