zoukankan      html  css  js  c++  java
  • Chrome headless在Linux上运行

    自动化测试中,web页面的用例一般会用selenium+Chrome Headless方式在Linux上运行,那么需要对Chrome进行以下的设置:

    import time

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options

    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-dev-shm-usage')
    chrome_options.add_argument("--start-maximized")
    driver = webdriver.Chrome('/usr/local/bin/chromedriver', options=chrome_options)
    driver.get('http://www.google.com/');
    print('open google')
    time.sleep(5) # Let the user actually see something!
    search_box = driver.find_element_by_name('q')
    search_box.send_keys('tiaaaaaaaaaaa')
    search_box.submit()
    time.sleep(5) # Let the user actually see something!
    print(driver.title)
    driver.quit()

  • 相关阅读:
    [算法]最长子数组问题
    [算法]K-SUM problem
    selenium-远程调用
    pytest-fixture
    Ubuntu18.04中安装virtualenv和virtualenvwrapper
    shell
    mac保存远程链接
    css
    js基础
    css基础
  • 原文地址:https://www.cnblogs.com/forwill/p/14606116.html
Copyright © 2011-2022 走看看