1.linux 下不能使用root開啟chrome
2.帶外掛程式開啟瀏覽器
options = webdriver.chromeoptions()
options.add_extension(「aliga.crx」)
browser = webdriver.chrome(chrome_options=options)
3.開啟新標籤(執行js)
js=』window.open(「
browser.execute_script(js)
4.獲取所有標籤
browser.window_handles 返回所有標籤頁名的list
5.切換到對應標籤
browser.switch_to.window() 根據標籤名切換到指定標籤上
最先開啟的標籤在標籤名陣列最末
開啟瀏覽器時的初始標籤排在第一位
6.close與quit的區別
close:關閉當前標籤(當只有乙個標籤時關閉後,新建新標籤)
quit:關閉瀏覽器
7.開啟無圖模式
prefs =
}options.add_experimental_option('prefs', prefs)
browser = webdriver.chrome(chrome_options=options)
Python Selenium環境搭建
安裝python 設定 python 的環境變數 安裝目錄 安裝目錄 scripts 使用 pip安裝 selenium pip install selenium 安裝完python pip工具,在安裝目錄的 scripts 目錄下。在 dos下直接執行 pip install selenium 即...
Python Selenium 學習筆記
1 判斷元素是否存在 try driver.find element.xx a true except a false if a true print 元素存在 elif a false print 元素不存在 2 判斷元素是否顯示 driver.find element by id outputb...
Python Selenium錯誤小結
因為要使用web應用,所以開始用起了,selenium包,安裝倒是挺容易的,但就是出了很多bug。filenotfounderror winerror 2 系統找不到指定的檔案。通過錯誤反饋發現是要把該軟體加到路徑裡面,但是,設定了系統環境變數後發現還是不行,最後,使用了乙個非常原始的方法 brow...