当我访问chrome://settings/help
网站,并试图通过XPath或其他渠道访问最新版本的Google时,我无法访问它.
我只是想得到最新版本的Chrome的字符串.
是否存在无法识别XPath的原因或特定情况?
错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main"]//settings-about-page//settings-section[1]/div[2]/div[2]/div[2]"} (Session info: chrome=114.0.5735.199);
请.帮助.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
import time
service = Service(executable_path="chromedriver")
options = webdriver.ChromeOptions()
options.add_argument('start-maximized')
driver = webdriver.Chrome(service=service, options=options)
driver.get('chrome://settings/help')
time.sleep(5)
update_check = driver.find_element(By. XPATH, '//*[@id="main"]//settings-about-page//settings-section[1]/div[2]/div[2]/div[2]').text
print(update_check)