当前位置:网站首页>Web test learning notes 01
Web test learning notes 01
2022-07-27 16:12:00 【FD vacation fish】

One 、 Syllabus
1. Core focus ( Chapter two )
2. Improve code quality , Automation level ( Third 、 Four 、 5、 ... and 、 Six chapters )
3. Project practice ( Chapter vii. )
4. Theory, environment and positioning ( Chapter one )
Two 、 Automation tools
2.1 Mainstream automation tools
1. QTP: charge Support ( Support web、 Desktop software automation )
2. selenium: free Open source Only support web project ( What to learn at present )
3. Robot framework: be based on python Extended Keyword Driven Automation Tools .2014 Stop updating in
2.2 What is? selenium?
One web Automated test tool , Chinese meaning : selenium
2.3 characteristic
1. Open source 、 free
2. Cross platform (Linux Windows mac)
3. Support for multiple browsers : Google firefox IE
4. Support for multiple languages :python、java... wait
5. Mature and stable : Has been Google 、 Baidu is widely used by large companies
6. Powerful : Support commercialization of most functions , And because of open source , The required functions can be customized .
2.4 selenium Family introduction
selenium1.0
1. selenium IDE ( Recording automated code tools )
2. selenium Grid ( Distributed tools ; Start multiple browsers at the same time )
3. selenium RC( adopt JS Simulation browser , Achieve automation )
selenium2.0( Stable version recommended )
selenium2.0 = selenium1.0+webdriver
selenium3.0
2.0 Upgraded version , Support JAVA8、windows10 、Edge browser 、safa browser
Tips : Whether through 2.0 still 3.0 Automated scripts written ,API The method is the same , The only difference is the environment
3、 ... and 、selenium
3.1 install
1) adopt pip Package management tools to install
install :
pip install selenium
see :
pip show selenium
uninstall
pip unstall selenium
Expand
1. Install the specified version pip install selenium== Version number Such as : pip install selenium==2.48.0
2. How to view installable versions ? Specify the wrong version number
3. pip yes python Medium package management tool ( Can install 、 uninstall 、 see python Tools )
4. pip list: Check through pip Plug ins or tools installed by package management tools
Tips :
1. Use pip It has to be networked
2. Default installation python3.5 Tools above version , Bring their own pip Package management tools , By default, it will be automatically installed and added path environment variable
2) adopt pycharm To install 【 recommend 】
Recommended reasons : Install into the current engineering environment
operation :
File( File menu )-->setting-->Project: Current project name -->Project Interpreter-- Click on + Install the corresponding package and version
Tips : If you use pip install The plugin name After installation , open pycharm , Guide operation , Prompt: this message cannot be found , That means using pip install
3.2 Browser and driver installation
browser
firefox : You can get the browser version on the official website or Baidu
Google : Through Baidu
drive :
1. firefox :
2. Google :
application :
1. Put the browser driver in the specified folder
2. Add the directory where the browser driver is located to the system Path In the environment variables
( Select my computer -- Right click -- attribute -- Advanced system setup -- senior ( environment variable )-->path( If it is win7 Semicolons need to be added between paths ))
Be careful :
1. The browser driver must correspond to the browser version ( When viewing the download driver , Browser version with notification response )
2. Get browser 48 Let's have a look at the version , Built in drive
3.3 The popular science Path
explain : Specify the directory that the system searches
dos Command default search order
1. Detect whether it is an internal command
2. Check whether it is an executable file in the current directory
3. Check path The directory specified by the environment variable
Tips :
1. If the input command or executable file cannot be checked in the search directory , The system will throw commands that are not internal or external ...
2. stay web Environment , If you don't add browser drivers to path in ,selenium When running, you will be prompted that the browser driver is wrong .
3.4 The first case
# Guide pack webdriver
from time import sleep
from selenium import webdriver
# Get Google browser objects
driver = webdriver.Chrome()
# Get Firefox browser object
# driver = webdriver.Firefox()
# Open the baidu
driver.get('http://www.baidu.com')
# Pause 3 second
sleep(3)
# Exit browser driver
driver.quit()
Four 、 Element localization
4.1 Why use element positioning ?
To use web Automation operation element , You must first find the element
4.2 Positioning tools
firefox :Firebug (F12 Get a direct click Firebug Icon )
Google :F12 key ( Developer tools )
4.3 What does it depend on when locating elements ?
1. Tag name
2. attribute
3. Hierarchy
4. route
4.4 Positioning mode
1.id
2.name
3.calss name( Using elements class Attribute positioning )
4.teg_name( Tag name < Tag name .../>)
5.link_text( Locate hyperlinks a label Fuzzy )
6.partial_link_text( Locate hyperlinks a label Fuzzy )
7.xpath( Based on element path )
8.css( Element selector )
Summary :
1. Based on the unique positioning method of element attributes (id\name\class_name)
2. Locate based on the element tag name :tag_name
3. Locate hypertext (link_text,partial_link_text)
4. Location based on element path (xpath)
5. Based on selector (css)
id location
explain :
1. By element id Attribute positioning ,id In general, it is unique in the current page
Method :
driver.find_element_by_id(id)
Tips :
The element has to have id attribute
Tips :
1. Input method : send_keys(" Input content ")
2. Exit browser driver :driver.quit():
3. open url : driver.get(url)
4. Guide pack : from selenium import webdriver
5. Get Firefox browser driver object drive = webdriver.Firefox()
name location
explain :
1. By element name Property to locate , name The general name is duplicate
Method :
drive.find_element_by_name(name)
Tips :
The element must have name attribute
class_name location
explain :
1. By element class Property to locate ,class Attributes are usually multiple values
Method :
drive.find_element_by_class_name()
Tips :
The element has to have class attribute
Tips :
id: Generally, it is a unique identification
name: You can rename
class: Multiple naming
Case study :
# Guide pack
from time import sleep
from selenium import webdriver
# Get browser object
driver = webdriver.Chrome()
# open url
url = "http://192.168.0.57:7890/gjydata/login.do"
driver.get(url)
# Look for the element user name and Input hyh
driver.find_element_by_name("userId").send_keys("hyh")
# Look for the element Password box and Input 1
driver.find_element_by_name("passwd").send_keys("1")
# Pause 3 second
sleep(3)
# Close the browser driver object
driver.quit()
边栏推荐
- juc包下常用工具类
- Flask connects to existing tables in MySQL database
- 43亿欧元现金收购欧司朗宣告失败!ams表示将继续收购
- openwrt 增加RTC(MCP7940 I2C总线)驱动详解
- 台积电的反击:指控格芯侵犯25项专利,并要求禁售!
- [sword finger offer] interview question 45: arrange the array into the smallest number
- Single machine high concurrency model design
- 解决flink启动后无法正常关闭
- Openwrt adds support for SD card
- Breaking through soft and hard barriers, Xilinx releases Vitis unified software platform for developers
猜你喜欢
随机推荐
JWT简介
DRF学习笔记(准备)
Content ambiguity occurs when using transform:translate()
Introduction and use of redis
时间序列-ARIMA模型
centos yum方式安装mysql
MySQL索引
Solve mt7620 continuous cycle uboot (LZMA error 1 - must reset board to recover)
juc包下常用工具类
DRF学习笔记(二):数据反序列化
flume增量采集mysql数据到kafka
Oracle 常用语句
Redis简介与使用
Vant UI toast and dialog use
使用transform:translate()出现内容模糊问题
Solve the compilation warning of multiple folders with duplicate names under the openwrt package directory (call subdir function)
Text capture picture (Wallpaper of Nezha's demon child coming to the world)
: 0xc0000005: an access conflict occurs when writing position 0x01458000 - to be solved
实现浅拷贝和深拷贝+
Enable shallow and deep copies+





![[sword finger offer] interview question 49: ugly number](/img/7a/2bc9306578530fbb5ac3b32254676d.png)



