zoukankan      html  css  js  c++  java
  • UI自动化框架搭建(一):selenium简单实现一个ui自动化脚本

    python版本:3.6.5,相关安装教程参考https://blog.csdn.net/a1173356881/article/details/82525960

    开发工具:pycharm,官网https://www.jetbrains.com/pycharm/download/#section=windows  社区版免费,专业版需要破解,破解注册码百度多尝试几次即可

     selenium版本:3.141.0,pip下载  pip install "selenium=3.141.0"   (定位元素参考地址:https://www.cnblogs.com/eastonliu/p/9088301.html)

    浏览器驱动 用的谷歌chromedriver版本87.0.4280.20,下载地址:http://chromedriver.storage.googleapis.com/index.html

    安装完成后编写一个简单的UI自动化脚本脚本测试,代码示例如下

    #coding:utf-8
    from selenium import webdriver
    import time
    
    # 实例化ChromeOptions
    options = webdriver.ChromeOptions()
    # 关闭浏览器提示信息
    options.add_argument('disable-infobars')
    # 浏览器全屏
    options.add_argument('start-fullscreen')
    
    # 驱动地址:需改成实际chromedriver.exe地址
    driverpath = r'D:angelangelautolittlebee1driverchromedriver.exe'
    driver = webdriver.Chrome(driverpath, options=options)
    # 访问百度首页
    driver.get(r"http://www.baidu.com")
    #百度输入框输入
    driver.find_element_by_id("kw").send_keys("懒勺")
    #点百度一下
    driver.find_element_by_id("su").click()
    time.sleep(3)
    driver.quit()

    python代码命名规范:

    模块一律小写,如有多个单词,用下划线隔开
    类名使用驼峰(CamelCase)命名风格,首字母大写,私有类可用一个下划线开头
    函数名一律小写,如有多个单词,用下划线隔开
    变量名尽量小写, 如有多个单词,用下划线隔开
    常量采用全大写,如有多个单词,使用下划线隔开

  • 相关阅读:
    oracle中pro*c的学习
    影响因子最大的国外计算机科学期刊50种
    eclipse3.6安装subversive插件
    WebLogic、WebSphere、JBOSS、Tomcat之间的区别
    hibernate.hbm.xml详解
    DotSpatial
    FLARtoolkit技巧:使用彩色marker
    全新体验 腾讯正式发布Sliverlight QQ
    ARToolKit技术视频欣赏
    写给未来的妻子你
  • 原文地址:https://www.cnblogs.com/heng-xin/p/14077938.html
Copyright © 2011-2022 走看看