zoukankan      html  css  js  c++  java
  • Linux 运行selenium

     

    1、进入google-chrome官网下载chrome安装包                        

        官网地址:https://www.google.cn/chrome/

        选择要下载的安装包

     2、安装Chrome

    rpm -ivh google-chrome-stable_current_x86_64.rpm
    

     如果报错如下信心:

    error: Failed dependencies:
    	liberation-fonts is needed by google-chrome-stable-87.0.4280.88-1.x86_64
    	libvulkan.so.1()(64bit) is needed by google-chrome-stable-87.0.4280.88-1.x86_64
    

      则:

    yum install liberation-fonts libvulkan.so.1*
    

     3、安装成功

     4、安装 selenium

    下载python3源码
    
    wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
    
    tar  xf Python-3.7.5.tgz ./
    cd Python-3.7.5
    编译
    
    ./configure --prefix=/usr/local/python3
    make&& make install
    
    ln -s /usr/local/python3/bin/python3 /usr/bin/python3
    ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
    
    pip3 install selenium
    pip3 install helium
    

    5、下载chrome dirver,然后放置到/usr/bin的目录下

    http://chromedriver.storage.googleapis.com/index.html

    6、运行demo

    #conding=utf-8
    from selenium import webdriver
    from helium import *
    
    
    option = webdriver.ChromeOptions()
    #option.add_argument('headless')
    option.add_argument('no-sandbox')
    option.add_argument('disable-dev-shm-usage')
    option.add_experimental_option('useAutomationExtension', False)
    option.add_experimental_option('excludeSwitches', ['enable-automation'])
    browser = webdriver.Chrome(chrome_options=option)
    
    browser.get('http://www.baidu.com/')
    print(browser.title)
    set_driver(browser)
    browser.quit()
    

      

  • 相关阅读:
    作业要求 20181009-9 每周例行报告
    20180925-1 每周例行报告
    作业要求20180925-4 单元测试,结对
    作业要求 20180925-3 效能分析
    作业要求 20180925-6 四则运算试题生成
    20180925-7 规格说明书-吉林市2日游
    20180925-5 代码规范,结对要求
    20170925-2 功能测试
    第二周例行报告
    作业要求 20180918-1 词频统计 卢帝同
  • 原文地址:https://www.cnblogs.com/royfans/p/14172613.html
Copyright © 2011-2022 走看看