首先,这是个问题贴,首先抛出我的困惑:
这是我写的代码:
public abstract class MyAndroidDriver<T extends WebElement> extends AndroidDriver<T> {
public MyAndroidDriver(URL remoteAddress, Capabilities desiredCapabilities) {
super(remoteAddress, desiredCapabilities);
}
public MyAndroidDriver(AppiumDriverLocalService service, Capabilities desiredCapabilities) {
super(service, desiredCapabilities);
}
public MyAndroidDriver(AppiumServiceBuilder builder, Capabilities desiredCapabilities) {
super(builder, desiredCapabilities);
}
public MyAndroidDriver(Capabilities desiredCapabilities) {
super(desiredCapabilities);
}
public void myss(){
}
}
Error:(15, 17) java: io.appium.java_client.AppiumDriver 中的 findElements(org.openqa.selenium.By) 无法实现 org.openqa.selenium.WebDriver 中的 findElements(org.openqa.selenium.By)
返回类型 java.util.List与 java.util.List不兼容
这里会报已错误,说的是 findByClassName 返回值类型不匹配!
我寻着这个 找到 AndroidDriver 类
public class AndroidDriver<RequiredElementType extends WebElement> extends AppiumDriver<RequiredElementType> implements AndroidDeviceActionShortcuts, HasNetworkConnection, PushesFiles, StartsActivity, FindsByAndroidUIAutomator<RequiredElementType> {
private static final String ANDROID_PLATFORM = "Android";
private final String METASTATE_PARAM = "metastate";
...
}
这个方法也是这么写的为啥没有报这个错呢
我有看了 appiumDriver 这个类
public abstract class AppiumDriver<RequiredElementType extends WebElement> extends DefaultGenericMobileDriver<RequiredElementType> {
private static final ErrorHandler errorHandler = new ErrorHandler(new ErrorCodesMobile(), true);
private URL remoteAddress;
private RemoteLocationContext locationContext;
private ExecuteMethod executeMethod;
protected final String KEY_CODE;
protected final String PATH;
private final String SETTINGS;
...
}
同样是酱紫,为啥我来继承它会报这个错
我就学着 AndroidDriver 的方式来继承 appiumDriver 这个类
public class MyAppiumDriver<T extends WebElement> extends AppiumDriver<T> {
public MyAppiumDriver(URL remoteAddress, Capabilities desiredCapabilities) {
super(remoteAddress, desiredCapabilities);
}
@Override
public T scrollTo(String s) {
return null;
}
@Override
public T scrollToExact(String s) {
return null;
}
}
同样类型的错误,我是实在找不到原因了,有没有大神能有这个问题解决呢?