当前位置:网站首页>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 ")
边栏推荐
猜你喜欢

深度學習19種損失函數

death_satan/hyperf-validate

Lenovo hybrid cloud Lenovo xcloud, new enterprise IT service portal

链表(一)——移除链表元素

Yygh-8-appointment registration

5g network overall architecture

Openharmony gnawing paper growth plan -- json-rpc

pytorch详解

Example of MVVM framework based on kotlin+jetpack

Jenkins continuous integration 1
随机推荐
Use of JDBC
How popular are FB and WhatsApp mass messages in 2022?
Idea automatically adds comments when creating classes
Working principle of es9023 audio decoding chip
The custom cube UI pop-up dialog supports multiple and multiple types of input boxes
Caused by: com. fasterxml. jackson. databind. exc.InvalidDefinitionException: Cannot construct instance
CSI以及本地盘的相关实现记录
OpenSCAP 简介
Use the SQL SELECT count distinct query statement to count the total number of unique values of a field in the database
Capacity scheduling absolute value configuration queue usage and pit avoidance
Taobao seo training video course [22 lectures]
使用pytorch和tensorflow计算分类模型的混淆矩阵
death_satan/hyperf-validate
Install fmpefg
CAD secondary development +nettopologysuite+pgis reference multi version DLL
What is the e-commerce conversion rate so abstract?
Filecoin hacker song developer competition
Sklearn Feature Engineering (summary)
慢内容广告:品牌增长的长线主义
高质量国产立体声编解码器CJC8988,Pin to Pin替代WM8988