å¦ä½ä½¿ç¨PythonåNoseå®ç°èªå¨åæµè¯ï¼
å¦ä½ä½¿ç¨PythonåNoseå®ç°èªå¨åæµè¯ï¼
æ¬ææå°è¯¦ç»ä»ç»ä½¿ç¨Appiumä¸çPythonç¼åçæµè¯çä¾å代ç 对ä¸ä¸ªiOSçæ ·ä¾åºç¨è¿è¡æµè¯ææ¶åçå个æ¥éª¤ï¼è对Androidåºç¨è¿è¡æµè¯æéçæ¥éª¤ä¸æ¤é常类似ã
ç¶åæç
§å®è£
æåï¼å¨ä½ çæºå¨ä¸å®è£
好Appiumã
æè¿éè¦å®è£
Appiumçææä¾èµå¹¶å¯¹æ ·ä¾appsè¿è¡ç¼è¯ãå¨Appiumçå·¥ä½ç®å½ä¸è¿è¡ä¸åå½ä»¤å³å¯å®ææ¤ä»»å¡ï¼
$ ./reset.sh --ios
ç¼è¯å®æåï¼å°±å¯ä»¥è¿è¡ä¸é¢çå½ä»¤å¯å¨Appiumäºï¼
$ grunt appium
ç°å¨ï¼Appiumå·²ç»è¿è¡èµ·æ¥äºï¼ç¶åå°±åæ¢å½åç®å½å°sample-code/examples/pythonãæ¥ç使ç¨pipå½ä»¤å®è£
ææä¾èµåº(å¦æä¸æ¯å¨èæç¯å¢virtualenvä¹ä¸ï¼ä½ å°±éè¦ä½¿ç¨sudoå½ä»¤)ï¼
$ pip install -r requirements.txt
æ¥ä¸æ¥è¿è¡æ ·ä¾æµè¯ï¼
$ nosetests simple.py
æ¢ç¶å®è£
å®æé软件并è¿è¡äºæµè¯ä»£ç ï¼å¤§è´äºè§£äºAppiumçå·¥ä½è¿ç¨ï¼ç°å¨è®©æ们è¿ä¸æ¥è¯¦ç»ççåæè¿è¡çæ ·ä¾æµè¯ä»£ç ã该æµè¯å
æ¯å¯å¨äºæ ·ä¾åºç¨ï¼ç¶åå¨å 个è¾å
¥æ¡ä¸å¡«åäºä¸äºå
容ï¼æå对è¿è¡ç»æåæææçç»æè¿è¡äºæ¯å¯¹ãé¦å
ï¼æ们å建äºæµè¯ç±»åå
¶setUpæ¹æ³ï¼
classTestSequenceFunctions(unittest.TestCase):
defsetUp(self):
app=os.path.join(os.path.dirname(__file__),
'../../apps/TestApp/build/Release-iphonesimulator',
'TestApp.app')
app=os.path.abspath(app)
self.driver=webdriver.Remote(
command_executor='127.0.0.1:4723/wd/hub',
desired_capabilities={
'browserName':'iOS',
'platform':'Mac',
'version':'6.0',
'app': app
})
self._values=[]
âdesired_capabilitiesâåæ°ç¨æ¥æå®è¿è¡å¹³å°(iOS 6.0)以åæ们æ³æµè¯çåºç¨ãæ¥ä¸æ¥æ们è¿æ·»å äºä¸ä¸ªtearDownæ¹æ³ï¼å¨æ¯ä¸ªæµè¯å®æååéäºéåºå½ä»¤ï¼
deftearDown(self):
self.driver.quit()
æåï¼æ们å®ä¹äºç¨äºå¡«åformçè¾
å©æ¹æ³å主æµè¯æ¹æ³ï¼
def_populate(self):
# populate text fields with two random number
elems=self.driver.find_elements_by_tag_name('textField')
foreleminelems:
rndNum=randint(0,10)
elem.send_keys(rndNum)
self._values.append(rndNum)
deftest_ui_computation(self):
# populate text fields with values
self._populate()
# trigger computation by using the button
buttons=self.driver.find_elements_by_tag_name("button")
buttons[0].click()
# is sum equal ?
texts=self.driver.find_elements_by_tag_name("staticText")
self.assertEqual(int(texts[0].text),self._values[0]+self._values[1])
æ¬æä»ç»å°æ¤ï¼ç¸ä¿¡å¾å¤æåé½å·²ç»æç½äºãä½æ¯å¦æä½ å¯¹NoseåPythonæ¥è¿è¡Appiumæµè¯æä»»ä½é®é¢æçæ³ï¼å¯ä»¥ç»æçè¨ï¼æ们å¯ä»¥ç»§ç»äº¤æµã
温馨提示:答案为网友推荐,仅供参考