用css来控制

coding:utf-8

引用webdriver

from selenium import webdriver

用来查找页面元素的类

from selenium.webdriver.common.by import By

睡眠时间

import time

path = r’D:\sele\chromedriver.exe’

打开浏览器

wd = webdriver.Chrome(executable_path=path)

wd.get(‘http://192.168.1.251:9012/ui/test/ex8’)
time.sleep(3)
wd.find_element(By.CSS_SELECTOR, “#input1”).send_keys(‘f1’)
wd.find_element(By.CSS_SELECTOR,
“#cross_srh > div > div.layui-inline > div.layui-inline > div:nth-child(2) > div > input”).send_keys(
‘f2’)
wd.find_element(By.CSS_SELECTOR,
‘#cross_srh > div > div.layui-inline > div.layui-inline > div.layui-inline > button:nth-child(1)’).click()
time.sleep(3)
wd.quit()

©️2020 CSDN 皮肤主题: 游动-白 设计师:上身试试 返回首页