我正在使用Appium用Python编写一些脚本来自动执行移动测试。我还将TestLink
用作测试管理工具,并且需要将自动化测试用例结果直接发布到testlink
。我试图为此目的使用TestLink-API-Python-Client。我知道可以从reportTCResult()
将结果更新为TestLink
,但是如何通过自动化测试的同一脚本来完成呢?
供参考,我有以下示例脚本;
# -*- coding: utf-8 -*-
import os, sys
import glob
import unittest
from appium import webdriver
from time import sleep
PLATFORM_VERSION = '5.1.1'
class EntranceTests(unittest.TestCase):
def setUp(self):
print 'commandline args',sys.argv[1]
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1.1'
desired_caps['deviceName'] = 'CooTel S32'
desired_caps['udid'] = sys.argv[1]
desired_caps['appPackage'] = 'com.android.phone'
desired_caps['appActivity'] = '.EmergencyDialer'
url = "http://localhost:{}/wd/hub".format(sys.argv[2])
self.driver = webdriver.Remote(url, desired_caps)
def emergency_dial(self):
number = self.driver.find_element_by_id('com.android.phone:id/digits')
number.send_keys("194")
dial = self.driver.find_element_by_id('com.android.phone:id/floating_action_button')
dial.click()
ok = self.driver.find_element_by_id('android:id/button1')
ok.click()
print 'SUCCESS! Emergency Dialer: Incorrect emergency number'
def emergency_dial2(self):
emergNum = self.driver.find_element_by_id('com.android.phone:id/digits')
emergNum.send_keys("911")
dial = self.driver.find_element_by_id('com.android.phone:id/floating_action_button')
dial.click()
#returncall = self.driver.find_element_by_xpath('//android.widget.Button[contains(@text, "Return to call")]')
#returncall.click()
sleep(10)
cancelcall = self.driver.find_element_by_id('com.android.dialer:id/floating_end_call_action_button')
cancelcall.click()
print "SUCCESS! Emergency Dialer: Correct emergency number-911"
self.driver.back()
def testcase2(self):
self.emergency_dial()
self.emergency_dial2()
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(EntranceTests)
unittest.TextTestRunner(verbosity=2).run(suite)