1.以谷歌浏览器的设置页面:
chrome://settings/
HTML页面元素
<select class="md-select" id="dropdownMenu" aria-label="字号">
<option value="9">特小</option>
<option value="12">小</option>
<option value="16">中(推荐)</option>
<option value="20">大</option>
<option value="24">特大</option>
<dom-repeat style="display: none;">
<template is="dom-repeat"></template>
</dom-repeat><option disabled="" value="SETTINGS_DROPDOWN_NOT_FOUND_ITEM"> 自定义
</option>
</select>
select 有三种定位元素的操作:
#获取select 元
s = driver.find_element_by_id("dropdownMenu")
# 根据value值
Select(s).select_by_value("9")
#根据索引
Select(s).select_by_index("1")
# 根据文本
Select(s).select_by_visible_text("特小")
完整代码,设置字体
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
driver = webdriver.Chrome()
driver.get("chrome://settings/")
s = driver.find_element_by_id("dropdownMenu")
Select(s).select_by_value(9)
driver.quit()
网友评论