【问题标题】:Method until(Function) in the type FluentWait is not applicable for the argumentsFluentWait 类型中的方法 until(Function) 不适用于参数
【发布时间】:2019-01-17 07:02:39
【问题描述】:

我遇到了until 方法通过 selenium webdriver 使用 appium 的问题。它抛出这个错误

FluentWait 类型中的方法 until(Function) 不适用于参数(new Function(){})

我遵循了prior posts 的所有选项,但没有一个有效。

使用 Java 1.8,在 POM 文件中添加了几乎所有依赖项。

public class AppInit {

    public static void setUp(AndroidDriver<AndroidElement> adriver) throws InterruptedException, MalformedURLException {
        ...........
        WebDriver driver;
        final WebDriverWait wait = new WebDriverWait(driver, 5);
        final By testXpath = By.xpath("////android.widget.Button[@content-desc='someid']");
        wait.until(ExpectedConditions.visibilityOfElementLocated(testXpath)).click();
   }

   public static void clickMenu() {
        WebDriver driver;
        new WebDriverWait(driver, 60).until(new Function<WebDriver, Boolean>() {
            Boolean isWindowFound = Boolean.FALSE;
            public Boolean apply(WebDriver driver) {
                try {
                   driver.switchTo().window("Your Window Name");
                   isWindowFound = Boolean.TRUE;
                } catch (NoSuchWindowException e) {
                   System.out.println("Your Window Name not found");
                   System.out.println(driver.getTitle());
                   return isWindowFound;
                }
                return isWindowFound;
            }
        });
    }

}

【问题讨论】:

    标签: java selenium selenium-webdriver appium


    【解决方案1】:

    添加以下依赖项已解决问题

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.5.2</version>
        </dependency>
    
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>23.0</version>
        </dependency>
    

    【讨论】:

      【解决方案2】:

      如果这对某人有帮助 - 我使用的是 Selenium-java 版本“3.141.59”并且能够使用 maven 编译项目但在 eclipse 中出现编译时错误,尽管我使用 maven 本身生成了 eclipse 项目设置。然后我只在下面添加了番石榴依赖项,我在 eclipse 中的编译时错误消失了

      <dependency>
              <groupId>com.google.guava</groupId>
              <artifactId>guava</artifactId>
              <version>23.0</version>
          </dependency>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-18
        • 2022-11-20
        • 1970-01-01
        • 1970-01-01
        • 2014-06-26
        相关资源
        最近更新 更多