1、跟大神交流,其中自己能学到很多的东西;
测试、框架、封装、用例工厂等等一系列专有名词;
最近有感觉自动化又进阶了一个阶段了,虽然觉得它现在存在的价值还不高,可是如果把UI界面做出了,还是挺值得的;
(1)终于封装了大部分的页面元素,用起来挺爽的;
(2)接下来需要做的就是要数据驱动了,可是是直接用excel,还是选择用数据库管理呢?
以下贴一小段代码:
1 import Means 2 import testlog 3 import traceback 4 import unittest 5 import HTMLTestRunner 6 from element_init import login_init,Pm_affiliate_search,Pm_affiliateDetail 7 class Test(unittest.TestCase): 8 def newaffiliate(self): 9 getrole=login_init.loginpage()10 getaffiliate=Pm_affiliate_search.affiliatesearch()11 affiliatedetail=Pm_affiliateDetail.affiliatedetail()12 chromedriver="D:\Program Files (x86)\Chrome\chromedriver.exe"13 os.environ["webdriver.chrome.driver"] = chromedriver14 browser = webdriver.Chrome(chromedriver) # Get local session of firefox15 browser.maximize_window()16 try:17 browser.get("http://192.168.1.20:9999") # Load page18 assert "login" in browser.title19 browser.implicitly_wait(2)20 Means.login(browser, '4@pc.com', '123456')21 assert "System Integration" in browser.title22 getrole.rolechosecm(browser).click()23 assert "http://192.168.1.20:9999/affiliate/cm/dashboard_index.html" in browser.title24 getaffiliate.affiliatesearchlist(browser).click() 25 assert "Affiliate List" in browser.title 26 time.sleep(1)27 getaffiliate.affiliateNew(browser).click()28 assert "http://192.168.1.20:9999/affiliate/CommonPages/affiliate_list.html" in browser.current_url29 affiliatedetail.LegalName(browser).send_keys("element test")30 affiliatedetail.DBAname(browser).send_keys("DBA Name")31 affiliatedetail.EntityType(browser).click()32 time.sleep(1)33 affiliatedetail.EntityTypeLLP(browser).click() 34 assert "LLP" in affiliatedetail.EntityTypeLLP(browser).text 35 affiliatedetail.State(browser).click()36 time.sleep(1)37 affiliatedetail.StateAS(browser).click()38 39 40 except Exception as e:41 print e42 msg = traceback.format_exc()43 testlog.logsys("运行失败", "控件没找到!"+ msg)