zoukankan      html  css  js  c++  java
  • python selenium 笔记

    1.安装环境  下载python 3.6.4 第一页把最下面的环境变量勾上。第二页把 all user  勾上  直接安装到下一步

    安装完成之后 cmd直接输入python  可以看到版本

    2.安装 selenium 

    pip install -U selenium

    3.下载最新的webdriver  

    PM> Install-Package Selenium.WebDriver.IEDriver -Version 3.9.0  vs直接用nuget安装

    4.打包 成EXE 可移植直接运行

    使用pip命令安装:pip install pywin32
    下载安装文件安装:官网

    pyinstaller.exe -F F:MyDemoCodec_mysqldedecaijidede_pydede_py.py 

    倒数第二行会出现打包之后的exe路径

    备注:可能移植的时候会出现这个问题unexpected error launching internet explorer protected mode settings are not the same for all zones

    设置-internet-安全-启用保护模式  全勾或者全不勾

    pip install -U pygame  pip安装的方法

    附:selenium 自动化python源码

    #coding=utf-8
    from selenium import webdriver
    import time
    import datetime
    
    import os
    os.getcwd()
    driver = webdriver.Ie()
    
    
    #登录
    driver.get("http://www.baocuole.com")
    driver.find_element_by_name("userid").send_keys('admin') 
    driver.find_element_by_name("pwd").send_keys('admin')
    driver.find_element_by_name("sm1").click()
    time.sleep(10) 
    
    #
    driver.get("http://www.baocuole.com")
    js = "document.getElementById('starttime').setAttribute('value','"+(datetime.date.today()-datetime.timedelta(days=1)).strftime("%Y-%m-%d")+"')" 
    driver.execute_script(js)
    driver.find_element_by_name("Submit").click()
    time.sleep(300) 
    
    #
    driver.get("http://www.baocuole.com")
    driver.find_element_by_name("b112").click()
    time.sleep(15) 
    driver.quit()
    

      

  • 相关阅读:
    一个好的时间函数
    Codeforces 785E. Anton and Permutation
    Codeforces 785 D. Anton and School
    Codeforces 510 E. Fox And Dinner
    Codeforces 242 E. XOR on Segment
    Codeforces 629 E. Famil Door and Roads
    Codeforces 600E. Lomsat gelral(Dsu on tree学习)
    Codeforces 438D The Child and Sequence
    Codeforces 729E Subordinates
    【ATcoder】D
  • 原文地址:https://www.cnblogs.com/muxueyuan/p/8473470.html
Copyright © 2011-2022 走看看