本帖最后由 zach14c 于 2022-10-19 16:29 编辑
ant design + react 确实比较花点时间
[Python] 纯文本查看 复制代码 from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
dr = webdriver.Firefox(executable_path='/home/aa/bin/geckodriver')
dr.get('https://09x.ant.design/components/pagination/')
element = WebDriverWait(dr, 10).until(
EC.presence_of_element_located((By.ID, "components-pagination-demo-changer"))
)
demo_div = dr.find_element_by_id('components-pagination-demo-changer')
opt_btn_span = demo_div.find_elements_by_class_name('ant-select-arrow')[0]
opt_btn_span.click()
WebDriverWait(dr, 10).until(
EC.visibility_of_element_located((By.CLASS_NAME, "ant-select-dropdown-menu-item"))
)
opt_menus = dr.find_elements_by_class_name('ant-select-dropdown-menu-item')
for opt_menu in opt_menus:
if opt_menu.text == '40 条/页':
dr.execute_script('arguments[0].click()', opt_menu)
|