2017-03-05 8 views
1

enter image description here私はappium pythonクライアントに新しく、以下の問題を解決するためにあなたの提案が必要です.PFA uiautomatorビューアenter image description hereスクリーンショットです。電子メールフィールドに入力した後、キーボードはそうパスワードを開き、ボタン、サインインを私は無料サンプルxxx.apkをダウンロードし、それをテストするためのスクリプトの下に作成した に配置されていない:appium pythonでロケータを見つけることができません

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("[email protected]"); 
     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.

以下試みたが、すべてが同じ理由で失敗している:

  • 要素= self.driver.find_element_by_id( "com.carezone.caredroid.careapp.medications:ID/welcome_page_sign_bton")

  • 要素= self.driver.find_element_by_accessibility_id( 'サインイン')

  • 要素= self.driver.find_element_by_android_uiautomator( '新しい UiSelector()。テキスト( "サインイン")')

答えて

0

は私のためにうまく働いた:

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 "Sign in Page" 
     element = self.driver.find_element_by_xpath("//android.widget.TextView[@text='Have an account? Sign In']") 
     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") 

     element.click() 
     element.send_keys("[email protected]"); 
     self.driver.implicitly_wait(3) 
     self.driver.keyevent(61) 

     element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_password_edit") 
     element.click() 
     element.send_keys("ni"); 
     self.driver.implicitly_wait(3) 
     print "Click TABS 2 times to get Sign In button-->>>>>>>" 
     self.driver.keyevent(61) 
     self.driver.keyevent(61) 


     element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_bton") 

     element.click() 
     self.driver.implicitly_wait(120) 
     print "TEST OK" 
1

試しIDによって要素を見つける:

  • 要素= self.driver.find_element_by_id( 'サインイン')

更新:

は、実行する前にhidekeyboard();を置くようにしてくださいあなたのキーボードを隠すために要素を選択するアクション!コードの下

+0

おかげ@Emnaを。私が気づいたのは、電子メールフィールドに入力するとキーボードがエミュレータで開くということです。ドライバがキーボードのためにパスワードフィールドや「サインイン」ボタンを見つけようとすると、ロケータが見つからない。これをどうやって解決できるの?エミュレータのスクリーンショットを添付 – JLyon

+0

私は私の答えを更新それをチェック! – Emna

+0

この質問への私の答えを参照してください:http://stackoverflow.com/questions/41977959/while-automating-login-process-with-appium-the-password-and-username-are-entred – Emna

関連する問題