自动化测试有感
1、?? 研究自動化測試也有一段時間了,從不熟悉到慢慢的了解,從不會到會,從迷茫到清晰......
前段時間一直都很疑惑,為什么要自動化,自動化能給我們帶來哪些好處?它存在的價值在哪里?運行一個腳本,執行的時候,難道還要盯著電腦屏幕去關注腳本運行的情況嗎?那還不如手動的去點擊呢?
迷茫疑惑的時候,建立多看看一些關于自動化測試的書籍,看看別人項目采用自動化測試,自動化測試給公司創造的價值;
比如:敏捷測試(里面有幾章是說自動化測試的)
自動化測試指南:
其他自動測試工具:
........
?2、從事測試行業也快一年了,說長不長,說短也不短,可是自己規劃自己的職業方向的時候,感覺很迷茫?不知自己以后的方向到底是咋樣的?自己是否真正的喜愛測試這個行業?還是當初為了生存才進入這個行業的?其實這跟我大學時的目標或者說理想有偏離了很多;進入測試行業之后,我開始了解功能測試,學習編寫測試用例的方法,學習自動化工具,學習JavaScript.....自己有時會很懷疑這是否就是自己想要的生活;
以下Share下最近寫的測試腳本吧:
def nessouring(): chromedriver="D:\Program Files (x86)\Chrome\chromedriver.exe"os.environ["webdriver.chrome.driver"] = chromedriverbrowser = webdriver.Chrome(chromedriver) # Get local session of firefoxbrowser.maximize_window()browser.get("http://192.168.1.20:9999") # Load pageassert "login" in browser.titlebrowser.implicitly_wait(2)Means.login(browser, '4@pc.com', '123456') #登錄pmtime.sleep(1)# Let the page load, will be added to the APIbrowser.find_element_by_xpath("//div[@class='pm tile double icon bg-color-redCustorm']/div/img").click() #using xpath to find elementtime.sleep(2)browser.find_element_by_xpath("//ul[@id='menu']/li/a").click()#click sourcingtime.sleep(1)browser.find_element_by_id("btnSearchNew").click()r=random.randint(1,1000)print rbrowser.find_element_by_id("LegalName").send_keys(r)browser.find_element_by_xpath("//div[@id='entityType']/div").click()time.sleep(2)entitytype=browser.find_element_by_xpath("//div[@id='entityType']/div[2]/ul/li[3]")print "輸出entitytype:%s" %(entitytype.text)entitytype.click() #drop list chosentime.sleep(2)browser.find_element_by_xpath("//div[@id='stateRegistered']/div").click()time.sleep(2)statere=browser.find_element_by_xpath("//div[@id='stateRegistered']/div[2]/ul/li[7]")statere.click() browser.find_element_by_xpath("//input[@id='OfficePhoneAreaCode']").send_keys("129")browser.find_element_by_xpath("//input[@id='OfficePhoneCentralOfficeCode']").send_keys("619")browser.find_element_by_xpath("//input[@id='OfficePhoneStationCode']").send_keys("1881")browser.find_element_by_xpath("//input[@id='ContactOfficeAreaCode']").send_keys("545")browser.find_element_by_xpath("//input[@id='ContactOfficeCentralOfficeCode']").send_keys("798")browser.find_element_by_xpath("//input[@id='ContactOfficeStationCode']").send_keys("3363")browser.find_element_by_id("SearchButton").click()if r==850 and entitytype.text=='Corporation' and statere.text=='California(CA)':alerts=browser.find_element_by_id("alertSearch")print "alert的提示信息是否為:This affiliate already exists in the system ! --- %s" %(alerts.text)browser.find_element_by_id("LegalName").send_keys('Simpleok!')time.sleep(1)browser.find_element_by_id("SearchButton").click()time.sleep(1)else:newbutton=browser.find_element_by_id("NewLeadButton")if newbutton.is_displayed():print "newbutton顯示出來了,直接點擊按鈕New Lead即可!"time.sleep(1)browser.find_element_by_id("NewLeadButton").click()else:print"存在相同的phone #或者是office #,需重新填寫phone # 或者Office #,需重新填寫;"browser.find_element_by_xpath("//input[@id='OfficePhoneAreaCode']").clear()time.sleep(1)browser.find_element_by_xpath("//input[@id='OfficePhoneAreaCode']").send_keys('829')browser.find_element_by_xpath("//input[@id='OfficePhoneCentralOfficeCode']").clear()browser.find_element_by_xpath("//input[@id='OfficePhoneCentralOfficeCode']").send_keys("739")browser.find_element_by_xpath("//input[@id='OfficePhoneStationCode']").clear()browser.find_element_by_xpath("//input[@id='OfficePhoneStationCode']").send_keys("1584")browser.find_element_by_xpath("//input[@id='ContactOfficeAreaCode']").clear()browser.find_element_by_xpath("//input[@id='ContactOfficeAreaCode']").send_keys("981")browser.find_element_by_id("SearchButton").click()time.sleep(1)browser.find_element_by_id("NewLeadButton").click()time.sleep(1) print "檢查當前頁面的URL:http://192.168.1.20:9999/affiliate/pm/sourcing_detail.html ! ---%s" %(browser.current_url)browser.find_element_by_xpath("html/body/form/div[1]/div[1]/button[1]").click()save_alert=browser.find_element_by_xpath("html/body/div[1]")if save_alert.is_displayed():print"save_alert被顯示了!顯示內容為:Please fill out all mandatory fields!f --- %s "%(save_alert.text)else:print"save_alert沒有顯示!! <此處有BUG>"time.sleep(1)?3、我是一個像空氣一樣自由的人,妨礙我心靈自由的時候,絕不妥協。轟轟烈烈的戀愛,舍命的讀書.
?
?
轉載于:https://www.cnblogs.com/tyen0921/p/3556245.html
總結
- 上一篇: Git删除不存在对应远程分支的本地分支
- 下一篇: 一个技术人的知识管理方法论