zoukankan      html  css  js  c++  java
  • web自动化:IE11运行Python+selenium程序

    from selenium import webdriver  # 运行此脚本前必须按要求修改注册表
    '''
    [HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_HTTP_USERNAME_PASSWORD_DISABLE]
    "iexplore.exe"=dword:00000000
    针对IE11,需要修改注册表。如果是32位的windows,key值为HKEY_LOCAL_MACHINESOFTWAREMicrosoftInternetExplorerMainFeatureControlFEATURE_BFCACHE
    ,如果是64位的windows,key值为HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftInternetExplorerMainFeatureControlFEATURE_BFCACHE
    如果key值不存在,就添加。之后在key内部创建一个iexplorer.exe,DWORD类型,值为0'''

    driver = webdriver.Ie()
    driver.get("http://www.baidu.com")
    #driver.get("http://admin:admin@10.82.21.145/")
    需要下载与Python版本对应的webdriver
    ie网页缩放比例要为100%大小,同时要注意Internet选项->安全,里面的保护模式全部勾选或者全部关闭。
    import win32api
    import win32con
    
    key = win32api.RegCreateKey(win32con.HKEY_CURRENT_USER,
                                'Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10')
    win32api.RegSetValueEx(key, ':Range', 0, win32con.REG_SZ, '10.82.21.190')
    win32api.RegSetValueEx(key, 'http', 0, win32con.REG_DWORD, 2)
    win32api.RegCloseKey(key)
    
    # IE安全保护模式全部取消
    key1 = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,
                               'Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1',
                               0, win32con.KEY_WRITE)
    win32api.RegSetValueEx(key1, '2500', 0, win32con.REG_DWORD, 3)  # 最后一个参数中(3:关闭,0:开启)
    win32api.RegCloseKey(key1)
    
    key2 = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,
                               'Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2',
                               0, win32con.KEY_WRITE)
    win32api.RegSetValueEx(key2, '2500', 0, win32con.REG_DWORD, 3)
    win32api.RegCloseKey(key2)
    
    key3 = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,
                               'Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3',
                               0, win32con.KEY_WRITE)
    win32api.RegSetValueEx(key3, '2500', 0, win32con.REG_DWORD, 3)
    win32api.RegCloseKey(key3)
    
    key4 = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,
                               'Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\4',
                               0, win32con.KEY_WRITE)
    win32api.RegSetValueEx(key4, '2500', 0, win32con.REG_DWORD, 3)
    win32api.RegCloseKey(key4)
    
    key5 = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,
                               'Software\Microsoft\Internet Explorer\Zoom',
                               0, win32con.KEY_WRITE)
    win32api.RegSetValueEx(key5, 'ZoomFactor', 0, win32con.REG_DWORD, 100000)
    win32api.RegCloseKey(key5)
    

      

  • 相关阅读:
    学习优化:训练深度神经网络进行无线资源管理
    (经典文章uplink)Information capacity and power control in single-cell multiuser communications(1995)
    Python运行出错
    2019之VLC3.071版本Ubuntu 18-win32-64为编译经验记录
    Ansys-CHEMKIN-pro表面反应机制输入(Surface Kinetics Input)规则
    tomcat9配置https
    tomcat和iis共用80端口的简明手册
    ANSYS经典APDL编程
    在ANSYS WORKBENCH中使用APDL命令的例子
    现代工程仿真CAE技术介绍
  • 原文地址:https://www.cnblogs.com/jieliu8080/p/10511395.html
Copyright © 2011-2022 走看看