1

我正在尝试运行一个迷你 appium 项目,我正在运行模拟器和 appium 服务器,这是我的代码,它说.getBinaryPath() is undefined for type WebDriverManager "caps.setCapability("chromedriverExecutable", WebDriverManager.chromedriver().getBinaryPath());"

package appiumBasics;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.github.bonigarcia.wdm.WebDriverManager;

@Test
public class RubWebApplicationAndroidEmulator {

    public void OpenWebApplication() throws MalformedURLException {
        DesiredCapabilities caps = new DesiredCapabilities();
    
        caps.setCapability(MobileCapabilityType.BROWSER_NAME, "chrome");
        caps.setCapability(MobileCapabilityType.DEVICE_NAME, "HaidyEmulator");
    WebDriverManager.chromedriver().setup();
    caps.setCapability("chromedriverExecutable", WebDriverManager.chromedriver().getBinaryPath());
        
    AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),caps);
    
    }
}
4

1 回答 1

0

那是因为如果你真的去存储库并打开有问题的类,你会发现没有为 定义这样的方法WebDriverManager

https://github.com/bonigarcia/webdrivermanager/blob/master/src/main/java/io/github/bonigarcia/wdm/WebDriverManager.java

大概这在某个时候被改变了。可能你需要WebDriverManager#getDownloadedDriverPath()

@Test
public class RubWebApplicationAndroidEmulator {

    public void OpenWebApplication() throws MalformedURLException {
        DesiredCapabilities caps = new DesiredCapabilities();
    
        caps.setCapability(MobileCapabilityType.BROWSER_NAME, "chrome");
        caps.setCapability(MobileCapabilityType.DEVICE_NAME, "HaidyEmulator");
    WebDriverManager.chromedriver().setup();
    caps.setCapability("chromedriverExecutable", WebDriverManager.chromedriver().getDownloadedDriverPath());
        
    AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),caps);
    
    }
}
于 2021-02-20T00:03:06.590 回答