亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Selenium Webdriver .get() 沒有打開窗口 - 沒有錯誤

Selenium Webdriver .get() 沒有打開窗口 - 沒有錯誤

侃侃無極 2022-07-26 17:08:28
我正在嘗試使用硒打開谷歌。當我運行它時,控制臺中不會出現任何錯誤,但是不會打開 chrome 窗口。程序簡單地終止。當我在 Chrome 78 上時,我在上一個項目中使用了幾乎相同的代碼(并且它有效)。它使用的是版本 80。from selenium import webdriverfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common import action_chains, keysfrom multiprocessing import Pool, cpu_count, freeze_supportimport osimport timePROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))DRIVER_BIN = os.path.join(PROJECT_ROOT, "chromedriver-80-mac")def get_driver():    options = webdriver.ChromeOptions()    options.add_argument('--headless')    driver = webdriver.Chrome(executable_path=DRIVER_BIN, options=options)    return driverdef test():    driver = get_driver()    driver.get('https://www.google.com')    time.sleep(3)    driver.quit()test()
查看完整描述

1 回答

?
RISEBY

TA貢獻1856條經驗 獲得超5個贊

您已指定無頭環境,這意味著您不會看到窗口。如果你想看到一個窗口,刪除這行代碼:

options.add_argument('--headless')


查看完整回答
反對 回復 2022-07-26
  • 1 回答
  • 0 關注
  • 192 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號