python selenium chrome有界面与无界面模式

驱动下载地址
http://chromedriver.storage.googleapis.com/index.html?


from selenium.webdriver.chrome.options import Options
from selenium import webdriver
 
 
# 无界面模式
def ChromeDriverNOBrowser():
   chrome_options = Options()
   chrome_options.add_argument('--headless')
   chrome_options.add_argument('--disable-gpu')
   driverChrome = webdriver.Chrome(executable_path="E:\\chromedriver",chrome_options=chrome_options)
    return driverChrome
 
# 有界面的就简单了
def ChromeDriverBrowser():
    driverChrome = webdriver.Chrome(executable_path="E:\\chromedriver")
    return driverChrome 
--------------------- 
作者:猎虫师 
来源:CSDN 
原文:https://blog.csdn.net/qq_28553681/article/details/82194689 
版权声明:本文为博主原创文章,转载请附上博文链接!

firefox和chrome都可以设置无界面模式。

我一般在调试脚步的时候,可以使用有界面的模式,这样可以看到元素定位的步骤。有时候用chrome打开项目时,需要定位的元素是排在li[0]的位置,但是selenium调用chrome打开,该元素排序就出现变化,至今未明白;所以只能在调试的时候,用有界面的模式看清楚元素定位的情况;

你可能感兴趣的:(python,web)