【发布时间】:2018-10-12 18:36:57
【问题描述】:
我正在为一个混合应用程序构建自动化,其中登录屏幕是一个反应 Web 视图,我无法控制它。 在密码输入字段中输入内容之前,登录按钮将被禁用。 Selenium 可以输入密码,但 react 无法识别更改,因此它永远不会启用按钮。 我正在为 appium 使用 python 库。
这是用于输入密码的 HTML:
<input type="password" class="TextInput--textInput__271qa TextInput-mobile--textInput__jba5n PasswordInput--password__8sQc8 TextInput--hasError__2DrJ8">
对于登录按钮:
<button class="Button--strongActionButton__154DS Button--mediumButton__Ga30r SignInScreen-mobile--signInButton__adj3k" type="submit" disabled="">Sign In</button>
这就是我将文本发送到密码输入字段并单击登录按钮的方式:
self.driver.switch_to.context(self.driver.contexts[-1])
self.driver.find_element_by_xpath("//input[@type='password']").send_keys("test_user@gmail.com")
self.driver.find_element_by_xpath("//button[@type='submit']").click()
最后一个动作是成功的,但是由于按钮被禁用所以它没有做任何事情。
我尝试过从 appium 触发 JS 事件,但没有成功。我也尝试过通过 JS 启用按钮,但仍然没有检测到输入的值。
感谢任何帮助,谢谢!
【问题讨论】:
-
使用相关的 HTML 和您的代码试验更新问题
-
@DebanjanB 刚刚更新,谢谢!
-
有点小技巧,但你可以尝试使用后台应用程序: self.driver.background_app(10) 并使用 self.driver.execute('mobile: activateApp', { bundleId : 'bundleid' }) 看看它是否更新?
标签: reactjs selenium selenium-webdriver webdriver appium