我是appium python客户端的新手,需要您的建议来解决下面的问题问题.PFAuiautomator查看器屏幕开枪了。不是当然,如果这是原因:输入电子邮件字段后,键盘会打开,因此密码和登录按钮都找不到 我下载了一个免费的样本xxx.apk公司并创建以下脚本进行测试:
class CareZoneAndroidTests(unittest.TestCase):
"Class to run tests against the Care Zone app"
def setUp(self):
"Setup for the test"
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.2'
desired_caps['deviceName'] = 'Android Emulator'
# Returns abs path relative to this file and not cwd
desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'D:/Programs/myapp/CareZone_v6.6.0.0 (flagship)_apkpure.com.apk'))
desired_caps['appPackage'] = 'com.carezone.caredroid.careapp.medications'
desired_caps['appActivity'] = 'com.carezone.caredroid.careapp.ui.activity.LandingActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def tearDown(self):
"Tear down the test"
self.driver.quit()
def test_login(self):
"Test the Login Page launches correctly"
self.driver.implicitly_wait(120)
print "After WAIT----------------->>>>>>>"
#Click on Sign in button
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_toolbar_action")
self.driver.implicitly_wait(15)
element.click()
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_mail_edit")
self.driver.implicitly_wait(10)
element.click()
element.send_keys("abc@ini.com");
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_password_edit")
element.click()
element.send_keys("abc");
self.driver.implicitly_wait(10)
#element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_bton")
#element = self.driver.find_element_by_accessibility_id('Sign In')
element = self.driver.find_element_by_android_uiautomator('new UiSelector().text("Sign In")')
element.click()
问题:
test_login (main.CareZoneAndroidTests) Test the Login Page launches correctly ... After WAIT----------------->>>>>>> ERROR
====================================================================== ERROR: test_login (main.CareZoneAndroidTests) Test the Login Page launches correctly ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\Programs\myapp\CareZoneTests.py", line 42, in test_login element = self.driver.find_element_by_android_uiautomator('new UiSelector().text("Sign In")') File "D:\Programs\Python275\lib\site-packages\appium\webdriver\webdriver.py", line 133, in find_element_by_android_uiautomator return self.find_element(by=By.ANDROID_UIAUTOMATOR, value=uia_string) File "D:\Programs\Python275\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 752, in find_element 'value': value})['value'] File "D:\Programs\Python275\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute self.error_handler.check_response(response) File "D:\Programs\Python275\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response raise wde NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
已在下面尝试,但都失败的原因相同:
元素=automator的self.driver.find_元素(新的 UiSelector().text(“登录”)')
尝试按ID查找元素:
更新时间:
在选择一个元素以隐藏你的键盘之前,试着把
hidekeyboard();
放进去!在下面的代码很适合我:
相关问题 更多 >
编程相关推荐