一个添加数据表单的脚本,代码能正常运行。当无头模式headless运行时,代码却无法运行。
chrome_options.add_argument("--headless") # 无头模式
错误提示:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
在添加两条代码后得以正常运行:
chrome_options.add_argument('window-size=1920x1080') # 窗口大小
chrome_options.add_argument('--start-maximized')
不明白其原理。
参考地址: