【问题标题】:Appium Native View, how to click the button to go back to the previous screenAppium Native View,如何点击按钮返回上一屏
【发布时间】:2021-10-14 03:37:04
【问题描述】:

我是 Appium 的新手,使用 UIAutomator2。按照链接上的说明进行操作:

[https://discuss.appium.io/t/click-back-button-on-android-device-in-java/6817/3][1] [https://discuss.appium.io/t/click-back-button-twice-in-android-7-using-appium-uiautomator2/20368][2] [https://stackoverflow.com/questions/30801879/how-to-automate-the-android-phone-back-button-using-appium][3]

我已经尝试了这些文章中提供的所有选项:

driver.pressKeyCode(4);

helper.driver.pressKeyCode(187);

driver.back();

driver.navigate().back();

如果我添加导入

导入 io.appium.java_client.android.nativekey.AndroidKey; 导入 io.appium.java_client.android.nativekey.KeyEvent; 我尝试 driver.pressKeyCode(AndroidKeyCode.BACK);

Eclipse 告诉我方法未定义...

但它们都没有奏效。我需要导入什么或需要创建任何其他类吗?我的驱动程序只有用于测试的方法,例如 close()、equals()、execute()、findElement()... 但没有类似 back()、pressKeyCode() 或 navigate()(这可能是因为它不是 webView)...所以,当我尝试键入任何这些方法时,Eclipse 要么建议添加演员表,要么创建一个类...

拜托,谁能给我一些关于如何做的更多细节?

【问题讨论】:

    标签: android navigation appium back android-uiautomator


    【解决方案1】:

    驱动程序应该是 Appium 驱动程序。并尝试在真实设备上运行而不是模拟器。

    driver = new AppiumDriver<>(url, desiredCapabilities);
    

    【讨论】:

    • 驱动最初定义为:/n AppiumDriver driver = new AndroidDriver(url, cap);
    • 然后主要是 driver.navigate().back();将工作。你在真机上试过吗?
    • 驱动声明是`AppiumDriver driver = new AndroidDriver(url, cap);`我试过你的,但是还是不行...
    猜你喜欢
    • 1970-01-01
    • 2014-10-05
    • 2020-02-15
    • 1970-01-01
    • 1970-01-01
    • 2020-05-29
    • 2016-10-26
    • 2011-04-03
    • 2012-05-12
    相关资源
    最近更新 更多