• 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()

  • 相关阅读:
    单调队列+二分 G
    dp cf 1700 最近几天的刷题
    dp 20190618
    dp 20190617
    dp cf 20190615
    dp cf 20190614
    powercli
    zabbix docker-weixin
    cenetos-大文件排序
    esxcli命令
  • 原文地址:https://www.cnblogs.com/forwill/p/14606116.html
Copyright © 2020-2023  润新知