即使 Selenium 4 可见也无法定位元素

问题描述 投票:0回答:0

我正在尝试将 Selenium 与 geckodriver 结合使用来单击某些元素。页面结构随更新更改后,无法单击此元素。要打开我正在使用的驱动程序:

from selenium import webdriver
from selenium.webdriver import FirefoxOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

options = FirefoxOptions()
options.binary_location = r'D:\Archivos de programas\firefox.exe'
profile_path = r'C:/Users/Isaac/AppData/Roaming/Mozilla/Firefox/Profiles/lpq195ye.eloimusqueira'

options.profile = profile_path

driver = webdriver.Firefox(options=options)
driver.get('http://www.faceit.com/en/tournaments')
element = driver.find_element(By.CSS_SELECTOR, 'div.sc-cjaHrE:nth-child(4) > a:nth-child(1)')
element.click()

但我得到的回报是它无法找到该元素。我正在调试,还等待了一些时间,所以我确定它是否对驱动程序可见但无法单击。这很奇怪,例如,左边的其他元素(见图(1))完全可以点击,没有任何问题。我该如何解决这个问题?提前致谢。

python selenium-webdriver selenium-firefoxdriver
© www.soinside.com 2019 - 2024. All rights reserved.