当前位置:网站首页>Drop down list processing in Web Automation
Drop down list processing in Web Automation
2022-06-28 06:07:00 【FamilyYan】
One 、select Drop down list processing
1、 Locate the select Elements
2、 choice select The attribute value
(1)、 adopt options Index selection drop-down content
sel.select_by_index(1)
(2)、 adopt options Of value Attribute value selection drop-down content
sel.select_by_value(“fiat”)
(3)、 adopt options Text content select the following content
sel.select_by_visible_text(“Audi”)
3、 I will choose directly , There is no page animation effect
Two 、select The drop-down list code implements processing

from selenium.webdriver.support.select import Select
from selenium import webdriver
import logging
import time
logging.basicConfig(level=logging.DEBUG)
# Start the browser driver server
driver = webdriver.Chrome()
driver.get("https://www.w3school.com.cn/tiy/t.asp?f=eg_html_elements_select")
driver.maximize_window()
time.sleep(2)
driver.switch_to.frame("iframeResult")
# location select Elements
ele_select = driver.find_element_by_xpath("//select")
sel = Select(ele_select)
# adopt options Index selection drop-down content
sel.select_by_index(1)
time.sleep(3)
# adopt options Of value Attribute value selection drop-down content
sel.select_by_value("fiat")
time.sleep(3)
# adopt options Text content select the following content
sel.select_by_visible_text("Audi")
3、 ... and 、div The drop-down list code implements
Click Baidu - Set up - Advanced search - Drop down boxes for all pages and files 
from selenium import webdriver
import logging
import time
logging.basicConfig(level=logging.DEBUG)
# Start the browser driver server
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
driver.maximize_window()
time.sleep(2)
# Click Settings
ele = driver.find_element_by_xpath('//span[@id="s-usersetting-top"]').click()
time.sleep(2)
# Click Advanced Search
driver.find_element_by_xpath('//div[@id="s-user-setting-menu"]//a[text()=" Advanced search "]').click()
time.sleep(2)
# Trigger drop-down list
driver.find_element_by_xpath('//span[text()=" All pages and files "]').click()
time.sleep(2)
# Get all the down lists
ele2 = driver.find_elements_by_xpath('//span[@id="adv-setting-ft"]//div[@class="c-select-dropdown-list"]/p')
for ele in ele2:
print(ele)
if ele.text == " All formats ":
ele.click()
else:
print(" Not all formats do not click ")
边栏推荐
- Maskrcnn, fast RCNN, fast RCNN excellent video
- 使用pytorch和tensorflow计算分类模型的混淆矩阵
- 自定义 cube-ui 弹出框dialog支持多个且多种类型的input框
- Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]]
- 安装 Ffmpefg
- AutoCAD C # Polyline Small Sharp angle Detection
- 5g network overall architecture
- MySQL(二)——基本操作
- Install fmpefg
- 深度學習19種損失函數
猜你喜欢

The windows environment redis uses AOF persistence and cannot generate an AOF file. After generation, the content of the AOF file cannot be loaded

Yygh-7-user management

高质量国产立体声编解码器CJC8988,Pin to Pin替代WM8988

Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance

YYGH-BUG-03

YYGH-6-微信登录

19 fonctions de perte d'apprentissage profond

Oracle fundamentals summary

CAD二次开发+NetTopologySuite+PGIS 引用多版本DLL问题

深度學習19種損失函數
随机推荐
深度學習19種損失函數
Jenkins continues integration 2
Difficulty calculation of Ethereum classic
Global country (and region) information JSON data
[MySQL] all query tables contain 20million data -- how to optimize SQL
Scripting and programming languages
Yygh-7-user management
Parsing ng template with let total in NZ Pagination
Idea generates entity classes from database tables
Windows环境Redis使用AOF持久化,无法生成AOF文件,生成后无法加载AOF文件内容
Object对象转 List集合
Prime mover × Cloud primordial is making sound, reducing cost and increasing efficiency lecture hall
easyui下拉框选中触发事件
Valueerror: iterative over raw text documents expected, string object received
Slow content advertising: the long-term principle of brand growth
What is the e-commerce conversion rate so abstract?
容量调度绝对值配置队列使用与避坑
Oracle fundamentals summary
YYGH-BUG-02
AutoCAD C polyline self intersection detection