Python Chromedriver找到xpath只要有头就可以了,但没有头就不行了

Python Chromedriver找到xpath只要有头就可以了,但没有头就不行了,python,selenium,xpath,Python,Selenium,Xpath,我建立了一个程序,它有不同的功能与一些谷歌服务交互,但首先它必须登录到指定的谷歌帐户。当chrome有一个head时,它可以正常工作,但是当我试图使它无头时,它找不到第一个元素的xpath,这是email字段。我得到的代码如下 from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument("--headle

我建立了一个程序,它有不同的功能与一些谷歌服务交互,但首先它必须登录到指定的谷歌帐户。当chrome有一个head时,它可以正常工作,但是当我试图使它无头时,它找不到第一个元素的xpath,这是email字段。我得到的代码如下

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("--headless")
driver = webdriver.Chrome(executable_path=r"C:\\path\\to\\chromedriver.exe", options=options)
然后它尝试使用指定的凭据登录

driver.get('https://accounts.google.com/signin/v2')
driver.find_element_by_xpath('//*[contains(@name,"identifier")]').send_keys('mail')
driver.find_element_by_xpath('//*[@id="identifierNext"]/content/span').click()
driver.find_element_by_xpath('//*[contains(@name,"password")]').send_keys('password')
driver.find_element_by_xpath('//*[@id="passwordNext"]/content/span').click()
而这在没有

 options.add_argument("--headless")
它不起作用,我也不知道为什么。在这件事上,如果有任何帮助,我将不胜感激。chrome和chromedriver均更新至最新版本