driver.getContextHandles()或driver.context()是否在Selenium4中删除,因为这些方法都是针对Appium驱动程序的?我使用Selenium 4.1.1和JavaClient- 8.0.0-beta2。
在Hybrind应用程序中运行测试时,面临查找元素的问题。场景一个Web视图在App中打开,点击一个图标。元素未找到异常将出现,而元素在Chrome中是唯一发现/标识的。
这方面的任何建议都将有助于进一步推动。
发布于 2022-02-11 06:49:18
关于driver.context() driver.context()问题的
这将转移到io.appium.java_client.remote.SupportsContextSwitching接口,该接口还包括默认实现。
在测试中,如果使用AppiumDriver,只需转换驱动程序,比如:
io.appium.java_client.remote.SupportsContextSwitching
((SupportsContextSwitching) driver).getContextHandles();注意:要想在没有ClassCastException的情况下完成这项工作,驱动程序最初应该以AndroidDriver或IOSDriver的形式创建,例如:
BaseOptions options = new UiAutomator2Options().setAutoGrantPermissions(true);
AppiumDriver driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), options);详细信息
我提到这一点,因为driver.context()是一个更大上下文的特例。
从版本7到appium java客户端版本8有很多变化。
其中之一:许多特定于平台且未被W3C WebDriver标准方法定义的方法移到了其他接口。
所以纯AppiumDriver没有这种方法。
但是,如果我们查看抛出代码(例如向AndroidDriver ),我们可以看到它实现了20+附加接口:
public class AndroidDriver extends AppiumDriver implements
PressesKey,
SupportsRotation,
SupportsContextSwitching,
SupportsLocation,
PerformsTouchActions,
HidesKeyboard,
HasDeviceTime,
...IOSDriver也是如此。
如果在AppiumDriver中找不到某些方法,请尝试抛出接口,AndroidDriver/ IOSDriver正在实现这些接口。
https://stackoverflow.com/questions/71075300
复制相似问题