Appium Test Case-Python?
?????Guanghe ???????[ 2016/12/29 11:33:49 ] ????????????????? Appium ??????????
????Appium??Client/Server??
????appium??????????????????????REST API??server
???????server????????????????????????????????client????????command????????Щcommand??????Щcommand???????豸????????????????????豸?????????豸???????Щcommand?????н???????appium server??appium server?????н???????client??
??????????client????????command???豸???????????????????е?????????appium??????????????????????????client???????????Щ?????????java/ruby/python/js????????????webdriver???Э??????
????Appium-Python-Client
????appium client???webdriver???api???Щ????????????????????????????д????????д???????????????????????????????webdriver???????????????????????????ɡ?
???????????????:
????pip install Appium-Python-Client
????HTMLTestRunner
?????????????
????HTMLTestRunner??Python??????е?????????????????????????????html???????
????????HTMLTestRunner.py???????HTMLTestRunner??????Python27Lib?????????
??????????÷??????????β????????????????
????Appium??Session
????session???????????webdriver/appium????????й????????????session start????????е?????????????POST /session???URL???????Desired Capabilities???????session???
????????session?????????????session id??????????е???????????????session id????????seesion id?????????????????????????????豸?????????
????Appium??Desired Capabilities
????Desired Capabilities?????session???????????????
????Desired Capabilities????????key value???????????appium server?????Щ???飺
????· ???β????????????????????????豸??
????· ?????andorid???????ios??
????· ???android???app??package??????
????· ???android???app??activity??????
????Appium??Desired Capabilities???????webdriver??Desired Capabilities??????????Щ????????
????· automationName?????????????????檔appium??????????Selendroid??
????· platformName????????????????iOS?? Android?? orFirefoxOS??
????· deviceName??????????豸??????????????????iPhone Simulator?? iPad Simulator?? iPhone Retina 4-inch?? Android Emulator?? Galaxy S4?? etc...
????· app??????·????????????·????????????appPackage??appActivity????????????????????????????????????browserName???????????
????· browserName?????????????????????Safari' for iOS and 'Chrome'?? 'Chromium'?? or 'Browser' for Android????app???????
???????????????android????????
????· appActivity?????????app??Activity?????????com.yangcong345.android.phone.presentation.activity.SplashActivity
????· appPackage?????????app??java package??????com.yangcong345.android.phone
?????????λ
??????appium???λ?????У???????Щ???????????????????????????????????漸????????????????webdriver??appium??DSL??????????????????п???????????????λ??
????· find by "class" (ui component type??andorid???????android.widget.TextView)
????· find by "xpath" (an abstract representation of a path to an element?? with certain constraints??????appium??xpath??????????????????)
????· find by "id"(android????????resource id)
????· find by name(??android??Button??????)
??????λ??????????:
????self.driver.find_elements_by_class_name('android.widget.TextView')
????self.driver.find_element_by_xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.Button[1]")
????self.driver.find_element_by_id('com.yangcong345.android.phone:id/rbStudent')
????self.driver.find_element_by_name(u'????')
???????÷???
???????Demo??????
????????λ????????????????????????find element??find elements???????????????????Щ???????????????????????
??????????:
????self.driver.find_element_by_id('com.yangcong345.android.phone:id/rbStudent').click()
????els = el.find_elements_by_class_name('android.widget.TextView')
????self.driver.scroll(els[len(els) - 1]?? els[0])
???????:????????ζ?λ???β
????el = self.driver.find_element_by_id('com.yangcong345.android.phone:id/mediacontroller_progress')
????self.assertIsNotNone(el)
????end = el.size.get('width')
????y = el.location.get('y')
????action = TouchAction(self.driver)
????action.tap(None?? end + 95?? y).perform()//???tap?????и?bug????????????None?????action???λ??Ч
???????г????????У?
????· ????????????
????· ????????????
????· ?Щ???????
??????????:
self.driver.find_element_by_id('com.yangcong345.android.phone:id/etUserName').send_keys('qq3@qqq.com')
el.get_attribute('checked')//????????????
self.assertEqual(el.get_attribute('checked')?? 'true')
self.assertIsNotNone(el)
//???к?????????????о???
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11