Appium / Android帮助让find元素工作

时间:2018-01-22 21:09:43

标签: selenium-webdriver appium-android python-appium

我是使用Selenium和Appium进行移动测试的新手。我们使用selenium web驱动程序来自动化我们的网站,并期待移动应用程序的自动化。

我希望我能找到一些快速指示。我无法选择此元素然后发送文本以开始登录过程,我已经研究了几个小时以找到可能的视频帮助等。

以下是Appium的屏幕截图,我正在尝试选择电子邮件字段,但我无法使用ID或xpath:https://screencast.com/t/KokZ2tCgjLG4

我希望找到该元素然后将密钥发送到该字段,以便我可以登录该应用程序。

这是我的代码:

def setUp(self):
desired_caps = {}
desired_caps[‘platformName’] = 'Android’
desired_caps[‘platformVersion’] = ‘8.0’
desired_caps[‘deviceName’] = ‘Pixel’
desired_caps[‘app’] = PATH(
’/Users/stevenrutherford/desktop/Android/foodlogiq-x86.apk’
)
desired_caps[‘appPackage’] = 'com.foodlogiq.connect’
desired_caps[‘appActivity’] = ‘.MainActivity’

    self.driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)


def test_login(self):
    time.sleep(15)

    email = self.driver.find_element_by_xpath("//*[@contentDescription='EMAIL ']") #I have try multiple options here
    email.click()

我似乎无法让Appium找到元素:

[HTTP] --> POST /wd/hub/session/a56058ad-94e9-4a69-a554-ad7bc3d2b6b7/element {“using”:“xpath”,“sessionId”:“a56058ad-94e9-4a69-a554-ad7bc3d2b6b7”,“value”:"//[@contentDescription='EMAIL ']"}
[MJSONWP] Calling AppiumDriver.findElement() with args: [“xpath”,"//[@contentDescription='EMAIL ']",“a56058ad-94e9-4a69-a554-ad7bc3d2b6b7”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//[@contentDescription='EMAIL ']",“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//[@contentDescription='EMAIL ']",“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//*[@contentDescription='EMAIL ‘]’ using ‘XPATH’ with the contextId: ‘’ multiple: false

此时它不会点击元素或向前移动甚至尝试输入电子邮件地址。

0 个答案:

没有答案