当前位置:网站首页>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()
边栏推荐
- 接连取消安富利/文晔/世平代理权,TI到底打的什么算盘?
- Hematemesis finishing c some commonly used help classes
- 云管平台中租户以及多租户概念简单说明
- [sword finger offer] interview question 42: the maximum sum of continuous subarrays -- with 0x80000000 and int_ MIN
- Delete node quickly and efficiently_ modules
- Addition, deletion, query and modification of MySQL table data
- Easy to understand, distinguish between ++i and I++
- 禁令之下,安防巨头海康与大华的应对之策!
- JSP Foundation
- Taking advantage of 5g Dongfeng, does MediaTek want to fight the high-end market again?
猜你喜欢

DRF学习笔记(五):视图集ViewSet

QT (VI) value and string conversion

: 0xC0000005: 写入位置 0x01458000 时发生访问冲突----待解

企业运维安全就用行云管家堡垒机!

Security software related to wireless network analysis (airtrack ng)

keil 采用 makefile 实现编译

Penetration test - dry goods | 80 + network security interview experience post (interview)

Scratch crawler framework

centos yum方式安装mysql

Nacos
随机推荐
减小程序rom ram,gcc -ffunction-sections -fdata-sections -Wl,–gc-sections 参数详解
flink打包程序提交任务示例
Clickhouse 20.x distributed table testing and chproxy deployment (II)
Paper_ Book
DRF学习笔记(准备)
Nacos
快速高效删除node_modules
Join hands with sifive, Galanz will enter the semiconductor field! Exposure of two self-developed chips
QT (VI) value and string conversion
Network device hard core technology insider router Chapter 22
DeFi安全之DEX与AMMs
Introduction and use of redis
三星关闭在中国最后一家手机工厂
Solve mt7620 continuous cycle uboot (LZMA error 1 - must reset board to recover)
MySQL表数据的增删查改
移动端h5常见问题
携手SiFive,格兰仕进军半导体领域!两款自研芯片曝光
时间序列-ARIMA模型
JSP基础
Determine the exact type of data