Python Automation Test - Chapter 2: Selenium

Python Automation Test - Chapter 2: Selenium,第1张

一、环境准备

1. install selenium:

pip install selenium

2. install chromedriver:

brew install chromedriver

3. confirm the version of chromedrive:

chromedriver --version

二、实例2

test google search in selenium

# 1. go to google.com
# 2. type in a search 'puppies'
# 3. submit or enter the search
# 4. assert we got a search page for puppies

1. how to find search box element in dev tool?

 (找到element)

2. submit or enter the search:

the name of "google search" element is unique:

 

to verify, we can execute this code in console:

$("[name='btnK']") 

 

3. example:

4. result:

 

三、statsroyale.com:

1. find cards page:

 verify it's unique:

2. find the element of the specific image:

 

$("[href*='Ice+Spirit']")

Note: ' *= ' means 'contains'

(want to get the href that contains the word "ice spirit")

 

3. example:

4. result:

 

 

 

 

 

 

 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/789256.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-05
下一篇 2022-05-05

发表评论

登录后才能评论

评论列表(0条)

保存