1、 研究自动化测试也有一段时间了,从不熟悉到慢慢的了解,从不会到会,从迷茫到清晰......
前段时间一直都很疑惑,为什么要自动化,自动化能给我们带来哪些好处?它存在的价值在哪里?运行一个脚本,执行的时候,难道还要盯着电脑屏幕去关注脚本运行的情况吗?那还不如手动的去点击呢?
迷茫疑惑的时候,建立多看看一些关于自动化测试的书籍,看看别人项目采用自动化测试,自动化测试给公司创造的价值;
比如:敏捷测试(里面有几章是说自动化测试的)
自动化测试指南:
其他自动测试工具:
........
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 |
def nessouring(): chromedriver = "D:\Program Files (x86)\Chrome\chromedriver.exe" os.environ[ "webdriver.chrome.driver" ] =
chromedriver browser =
webdriver.Chrome(chromedriver) # Get local session of firefox browser.maximize_window() assert
"login" in browser.title browser.implicitly_wait( 2 ) Means.login(browser, ‘4@pc.com‘ , ‘123456‘ ) #登录pm time.sleep( 1 ) # Let the page load, will be added to the API browser.find_element_by_xpath( "//div[@class=‘pm tile double icon bg-color-redCustorm‘]/div/img" ).click() #using xpath to find element time.sleep( 2 ) browser.find_element_by_xpath( "//ul[@id=‘menu‘]/li/a" ).click() #click sourcing time.sleep( 1 ) browser.find_element_by_id( "btnSearchNew" ).click() r = random.randint( 1 , 1000 ) print
r browser.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 chosen time.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 ) |
原文:http://www.cnblogs.com/tyen0921/p/3556245.html