是否在 Selenium4 中洗掉了 driver.getContextHandles() 或 driver.context(),因為這些方法即將用于 Appium 驅動程式?我正在使用 Selenium 4.1.1 和 JavaClient-8.0.0-beta2。
在 Hybrind 應用程式中運行測驗時面臨查找元素的問題。場景 單擊圖示后,Web 視圖正在 App 中打開。元素未找到例外即將到來,而元素在 Chrome 中是唯一找到/識別的。
這方面的任何建議都將有助于進一步處理。
uj5u.com熱心網友回復:
關于關于的問題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()它是更大背景下的一個特例。
appium java客戶端版本8相比版本7有很多變化。
其中之一:許多特定于平臺且未由 W3C WebDriver 標準方法定義的方法移出到其他介面。
所以pureAppiumDriver沒有這個方法。
但是如果我們看一下 throw 代碼,例如 to AndroidDriver,我們會看到它實作了 20 多個附加介面:
public class AndroidDriver extends AppiumDriver implements
PressesKey,
SupportsRotation,
SupportsContextSwitching,
SupportsLocation,
PerformsTouchActions,
HidesKeyboard,
HasDeviceTime,
...
和同樣的IOSDriver。
如果在 中找不到某些方法AppiumDriver,請嘗試拋出AndroidDriver/IOSDriver正在實作的介面。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/424670.html
標籤:硒网络驱动程序 自动化 android-webview 应用 混合移动应用
上一篇:使用XPath在HTML中選擇帶有標簽內容而不是編號串列的按鈕
下一篇:FileNotFoundError:[Errno2]Nosuchfileordirectory:'2022_06_02/10/22_17_06.txt'將抓取的資料寫入txt檔案時
