当前位置:网站首页>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()
边栏推荐
- [sword finger offer] interview question 39: numbers that appear more than half of the time in the array
- [sword finger offer] interview question 52: the first common node of two linked lists - stack, hash table, double pointer
- [sword finger offer] interview question 54: the k-largest node of the binary search tree
- C language realizes the conversion between byte stream and hexadecimal string
- Easy to understand, distinguish between ++i and I++
- Security software related to wireless network analysis (airtrack ng)
- Have you ever used the comma operator?
- Busybox login: can't execute'/bin/bash': no such file or directory solution
- __ The difference between typeof and typeof
- keil 采用 makefile 实现编译
猜你喜欢

juc包下常用工具类

Excel提取重复项
![[sword finger offer] interview question 50: the first character that appears only once - hash table lookup](/img/72/b35bdf9bde72423410e365e5b6c20e.png)
[sword finger offer] interview question 50: the first character that appears only once - hash table lookup

The risk of multithreading -- thread safety
![[sword finger offer] interview question 42: the maximum sum of continuous subarrays -- with 0x80000000 and int_ MIN](/img/01/bbf81cccb47b6351d7265ee4a77c55.png)
[sword finger offer] interview question 42: the maximum sum of continuous subarrays -- with 0x80000000 and int_ MIN

centos上mysql5.7主从热备设置

drf使用:get请求获取数据(小例子)

MySQL表数据的增删查改

DRF学习笔记(二):数据反序列化
![[sword finger offer] interview question 54: the k-largest node of the binary search tree](/img/13/7574af86926a228811503904464f3f.png)
[sword finger offer] interview question 54: the k-largest node of the binary search tree
随机推荐
渗透测试-干货 | 80篇+网络安全面试经验帖(面试篇)
Breaking through soft and hard barriers, Xilinx releases Vitis unified software platform for developers
多行文本溢出打点
Flask connects to existing tables in MySQL database
Embedded development: tips and techniques -- seven techniques to meet the real-time deadline
无线网络分析有关的安全软件(aircrack-ng)
Pycharm导入已有的Project
SQL multi table query
测试新手学习宝典(有思路有想法)
Paper_ Book
时间序列——使用tsfresh进行分类任务
Oracle 常用语句
新版jmeter函数助手不在选项菜单下-在工具栏中
[sword finger offer] interview question 50: the first character that appears only once - hash table lookup
C language realizes the conversion between byte stream and hexadecimal string
Pycharm导入已有的本地安装包
这些题~~
Openwrt new platform compilation
Solve mt7620 continuous cycle uboot (LZMA error 1 - must reset board to recover)
C: On function