2017-11-30 2 views
0

型待ちで(機能)までのメソッドは、引数には適用されません(新しい関数(){})セレンwebdriverをして​​私のコードをコンパイルしている間、私はこのエラーを得た

@BeforeClass setUp java.lang.Error: Unresolved compilation problems: The method until(Function) in the type Wait is not applicable for the arguments (new Function(){}) Function cannot be resolved to a type

私のコードは次のとおりです。

Wait wait = new FluentWait(driver)  
      .withTimeout(30, SECONDS)  
      .pollingEvery(5, SECONDS) 
      .ignoring(NoSuchElementException.class); 

    WebElement myLoginButton = wait.until(
     new Function() {  
      public WebElement apply(WebDriver driver) {  
       return driver.findElement(By.id("btnLogin"));  
      } 
     } 
    ) 
+0

コードを見ると、達成しようとしていることを判断するのが少し難しいです。このブロックに関連する共有していないコードがありますか? 'new Function(){ public WebElement apply(WebDriver driver){ return driver.findElement(By.id(" btnLogin ")); } ' – Reezo

答えて

0

独自の機能を作成するには、Function<? super WebDriver, ?>機能を提供する必要があります。

それとも、新しいオブジェクトExpectedCondtions

例作成:

Wait wait = new FluentWait(driver)  
      .withTimeout(30, SECONDS)  
      .pollingEvery(5, SECONDS) 
      .ignoring(NoSuchElementException.class); 

WebElement myLoginButton = wait.until(
    new ExpectedCondition<WebElement>() {  

      public WebElement apply(WebDriver driver) {  
       return driver.findElement(By.id("btnLogin"));  
     } 
    } 
) 
0

をあなたはFluentWaitのために使用された引数&の構文を使用して、いくつかのマイナーな問題がありました。ここにあなたの作業コードブロックはあります: