Yellow 就怕你碌碌无为,还安慰自己平凡可贵 -------------yolo

最新的selenium操作记录

import time

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

from selenium.webdriver.chrome.service import Service

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

d = webdriver.Chrome('/home//chromedriver',chrome_options=chrome_options)

s = Service('/opt/scripts/BI/chromedriver') # 存储驱动所在路径
d = webdriver.Chrome(service=s,chrome_options=chrome_options) # 从路径提取驱动,设置驱动名为d
d.implicitly_wait(10) # 设置每个步骤最大等待时间
d.get('http://10.0.18.5:37799/webrXXX') # GET方法访问百度
d.find_element('xpath', '//*[@id="wrapper"]/div[1]/div/div[2]/div/div/div[1]/div[1]/div[1]/div[1]/div[2]/input').send_keys("admin")
d.find_element('xpath','/html/body/div/div[1]/div/div[2]/div/div/div[1]/div[2]/div[1]/div[1]/div[2]/input').send_keys('dXXX2021')
d.find_element('xpath','/html/body/div/div[1]/div/div[2]/div/div/div[1]/div[4]/div').click()
time.sleep(3)
d.find_element('xpath','/html/body/div[5]/div/div/div[2]/i').click()

d.find_element('xpath','/html/body/div[1]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div[1]/div[5]/div/div/div[1]/div/div/div/div/div[16]/div/div[4]').click()

医美

print("医美")
d.find_element('xpath','/html/body/div[1]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div[1]/div[5]/div/div/div[1]/div/div/div/div/div[16]/div[2]/div/div[1]/div[3]').click()
time.sleep(200)
print("齿科")

齿科

d.find_element('xpath','/html/body/div[1]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div[1]/div[5]/div/div/div[1]/div/div/div/div/div[16]/div[2]/div/div[2]/div[3]').click()
time.sleep(200)

print("外科")

外科

d.find_element('xpath','/html/body/div[1]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div[1]/div[5]/div/div/div[1]/div/div/div/div/div[16]/div[2]/div/div[3]/div[3]').click()
time.sleep(200)

眼科

d.find_element('xpath','/html/body/div[1]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div[1]/div[5]/div/div/div[1]/div/div/div/div/div[16]/div[2]/div/div[4]/div[3]').click()
time.sleep(200)
print("结束")
d.close()

posted @ 2022-05-13 17:08  zfno11  阅读(52)  评论(0编辑  收藏  举报