• 最新的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()

  • 相关阅读:
    Python 循环语句
    Python if、elif 、else语句 与 布尔运算
    Python 运算符
    Python 标识符
    Python 常用数据类型(整数,浮点数,复数,布尔型)
    Python 编辑器内容
    Python 语言介绍
    vscode 最新中文设置
    漫画数据库_基础和设计数据库
    linux配置服务器
  • 原文地址:https://www.cnblogs.com/ZFBG/p/16267421.html
Copyright © 2020-2023  润新知