First, install Selenium and environment configuration
1 pip Install Selenium
23 Drive files to D: Packing directory
3 Installing Firefox version 33
4 Installation Plug-in: Selenium Ide\firebug\firepath
5 download three py program, respectively, the path is set to the path of three drive files, and then execute separately, see if you can open the browser, display Sogou page, there is a successful can
"Step on the pit."
IE browser words need to be set
1, Zoom 100%
2, full check or not check the selection
II. Automation test 1, Automation Testing Advantages: (1) Save time when repeated execution, improve test coverage (2) automation regression (3) Normalization process (4) Historical documentation 2, limitations of automated Testing: (1) only 15% bugs (2) can be found that do not improve test effectiveness, can only improve efficiency (3) No imagination, no one smart (4) Can not replace the manual test 3, the content of automated testing: (1) automatic test data Generation (2) automation input (3) test results automatic comparison (4) test automation (5) Management of test Cases (6) Online monitoring 4, Automated Scripting Techniques: (1) linear scripting (2) structured script (3) shared script (4) Data-driven script (5) keyword-driven scriptData-Driven Scripting example: program invariant data changes
Data.txt:E:\\a.txte:\\1.html
main.py:#encoding =utf-8 with open ("Data.txt") as Fp:for I in Fp:with open (I.strip ()) as Fp1:print Fp1.read ()keyword driven pin This example: Invoke a function in another file by using a keyword in the data file to implement a function. The test logic is decomposed by these keywords to form a data file that encapsulates the test logic in a data file in the form of keywords, and the test tools can be applied automatically as long as they are able to interpret the keywords. #练习: (1) Use OP as the keyword in the data.txt file, call the OP () method in kd.py to read all the contents of the 1.txt file, (2) the second to third row of data in the Data.txt file with "," distinction, write and read as the type of operation; e : \\test4\\ ... As Operation Path; W and R as Operation Rights; Glory Road is good!"To write content;
kd.py:#encoding =utf-8def op (): With open ("E:\\test4\\1.txt") as Fp:print Fp.read () def write (file_path,mode,content): With open (File_path,mode) as Fp1:fp1.write (content) def read (File_path,mode): with open (File_path,mode) as Fp2:print Fp2.read ()
kd2.py:#encoding =utf-8from KD Import * with open ("E:\\test4\\data.txt") as fp: for I in fp: If I.find (",")!=-1: Prams=i.strip (). Split (",") If Len (prams) ==4: command=prams[0]+ "(\" +prams[1]+ "\ ", \" "+prams[2]+" \ ", \" "+prams[3]+" \ ")" Print command & nbsp eval (command) If Len (prams) ==3: &N Bsp command=prams[0]+ "(\" "+prams[1]+" \ ", \" "+prams[2]+" \ ")" & nbsp print command eval (command) &NBSP ; else: Prams=i.strip () COMM and=prams+"()" print command eval (command)
Data.txt:Opwrite,e:\\a.txt,w,glory Road is Good!read,e:\\a.txt,r
1. txt:Process-2:2018-03-31 15:02:31glory Road is good!
5, the use of some typical automation scenarios: (1) A large number of regression test (2) Injection test data (3) Agile Development of TDD mode, behavior-driven Development mode (4) Mechanical and cumbersome testing (5) Business monitoring 6, Automation terminology: (1) Framework: Reusable design of whole or part of the system, Can be seen as an application of the skeleton (2) keyword-driven automated testing: mainly including manipulated objects, operations, and values
"Python" UI Automation-1