当前位置:网站首页>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 ")
边栏推荐
- SQL and list de duplication
- What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?
- lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
- How the third-party libraries in cocoapod reference local header files
- ThreadLocal
- 6. graduation design temperature and humidity monitoring system (esp8266 + DHT11 +oled real-time upload temperature and humidity data to the public network server and display the real-time temperature
- Openharmony gnawing paper growth plan -- json-rpc
- Windows环境Redis使用AOF持久化,无法生成AOF文件,生成后无法加载AOF文件内容
- easyui下拉框选中触发事件
- ipvs 导致syn 重传问题
猜你喜欢

ES9023音频解码芯片的工作原理

Drop down box for implementation

The custom cube UI pop-up dialog supports multiple and multiple types of input boxes

YYGH-BUG-02

Sklearn Feature Engineering (summary)

AutoCAD C polyline self intersection detection

深度學習19種損失函數

Deep learning 19 loss functions

慢内容广告:品牌增长的长线主义
![RL practice (0) - and the platform xinchou winter season [rule based policy]](/img/dc/10d615c64123475fea180e035095ff.png)
RL practice (0) - and the platform xinchou winter season [rule based policy]
随机推荐
Introduction to openscap
cocoapod中的第三方库怎么引用本地头文件
Windows环境Redis使用AOF持久化,无法生成AOF文件,生成后无法加载AOF文件内容
Use of JDBC
移动广告发展动向:撬动存量,精细营销
不会还有人只会用forEach遍历数组吧?
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance
Install redis on windows and permanently change the password, and integrate redis with the SSM framework
Drop down box for implementation
Valueerror: iterative over raw text documents expected, string object received
How popular are FB and WhatsApp mass messages in 2022?
脚本语言和编程语言
链表(二)——设计链表
JSP
easyui 重置多条件查询
深度学习19种损失函数
Socket. Io long Connection Push, version Control, Real - Time Active user volume Statistics
No one can only use foreach to traverse arrays, right?
Filecoin hacker song developer competition
windows上安装redis并永久修改密码,及ssm框架集成redis