我目前遇到一个问题:我无法用简单的代码打开Chrome中任何页面的URL。
Chrome 窗口会出现,询问谁当前正在使用 Chrome,您可以在其中选择配置文件,但它很快就会消失,并且我的程序会出错。
import time
import pyautogui
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from pynput.keyboard import Key, Controller
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from seleniumbase import Driver
service = Service()
options = webdriver.ChromeOptions()
#driver = webdriver.Chrome(service=service, options=options)
driver = Driver(browser="chrome", headless=False)
url = "https://www.google.de/"
driver.get(url)
这样的窗口:
一个简单的形式是:
from selenium import webdriver
import time
#for deutsch in browser
option = webdriver.ChromeOptions()
option.add_argument("lang=de")
driver = webdriver.Chrome(options=option)
driver.get("https://www.google.de/")
time.sleep(5)
driver.quit()