• 【无标题】


    # 引入selenium

    from selenium import webdriver

    # 引入延迟时间

    from time import sleep
    class casetest(object):
    def init(self):
    # 打开谷歌浏览器
    self.browser = webdriver.Chrome()
    # 打开网址
    self.browser.get(“https://jmtest.jumingedu.com/qkyx”)
    # 延迟2秒
    sleep(2)

    #方法1  把谷歌浏览器放大
    def test_execoute1(self):
        self.browser.maximize_window()
        sleep(1)
    
    #点击学员登录
    def test_execoute2(self):
        self.browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[1]/div[2]/div[3]/div/div[4]/div[1]").click()
    # 输入手机号和密码和验证码
    # 点击登录
    def test_execoute3(self):
        self.browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[2]/div[2]/div/div/div[1]/input").send_keys('19990000318')
        self.browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[2]/div[2]/div/div/div[2]/input").send_keys('Jm@123456')
        self.browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[2]/div[2]/div/div/div[3]/input").send_keys('8888')
        self.browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[2]/div/div[2]/div[2]/div/div/div[4]/button").click()
        sleep(5)
    #点击继续教育
    def test_execoute4(self):
        self.browser.find_element_by_xpath("/html/body/div[1]/div/div[1]/div[2]/div/div[1]/li[3]/div").click()
        sleep(2)
        # 点击图片进入详情页面
        self.browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[2]/div[1]/div/li[2]/div[1]").click()
        sleep(3)
        # 点击开始
        self.browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[1]/div/div[2]/div[2]/div[4]/div[1]/div/div[1]").click()
        sleep(3)
        # 点击开始播放
        self.browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[1]/div/div[2]/div[1]/div/div[1]/div[1]/div").click()
        sleep(3)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29

    调用方法

    if name == ‘main’:
    # 调用casetest方法
    case = casetest()
    #调用 casetest中的test_execoute1
    case.test_execoute1()
    case.test_execoute2()
    case.test_execoute3()
    case.test_execoute4()

    import time

    桌面自动化

    import pyautogui as pya

    实时获取鼠标的当前位置

    try:
    while True:
    # 获取屏幕分辨率
    screenWidth, screenHeight = pya.size()
    # 获取鼠标位置
    x, y = pya.position()
    # 打印分辨率和鼠标位置
    print(“Screen size: (%s %s), Position : (%s, %s)\n” % (screenWidth, screenHeight, x, y))
    # 间隔三秒显示位置
    # time.sleep(3)
    n = 0;
    while n < 100:
    n = n + 100
    # 点击指定位置
    pya.click(971, 706)
    # time.sleep(1)
    pya.typewrite(‘cnm’)
    pya.click(1407, 786)
    time.sleep(1)
    except KeyboardInterrupt:
    print(‘end’)
    pya.click

  • 相关阅读:
    String字符串方法
    一文详解 requests 库中 json 参数和 data 参数的用法
    web前端开发 乱七八糟的 奇怪操作
    GEE:LST地表温度反演函数
    Linux下Doris1.1+Mysql安装启动
    如何将 JavaScript Excel XLSX 查看器添加到Web应用程序
    SDL_Image STB_Image 中文路径
    在线考试系统
    PHP留言反馈管理系统源码
    漫谈ERP和MES数据打通
  • 原文地址:https://blog.csdn.net/weixin_48992836/article/details/126827372