Python Selenium错误:元素在该位置不可点击

2024-04-26 02:47:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用python上的selenium来刮这个网站每次我试图点击div标签中的下拉按钮时都会出现这个错误请帮我一些忙错误是“元素在点(1341,240)处不可点击”下面是这个网站

'https://tennisinsight.com/player/56330/andrea-gamiz/'

如果你滚动到页面的底部,我试图点击match stats部分的duration下拉选项。下面是我目前的代码


    driver = webdriver.Chrome()  
    driver.maximize_window()
    wait = WebDriverWait(driver, 5)
    small_wait = WebDriverWait(driver, 5)

    driver.execute_script('window.open("https://tennisinsight.com/player/56330/andrea-gamiz/","_self")')
    driver.execute_script("document.body.style.zoom='75%'")
    from selenium.webdriver.common.keys import Keys
    html = driver.find_element_by_tag_name('html')
    html.send_keys(Keys.END)
    time.sleep(3)   
    element = wait.until(EC.element_to_be_clickable((By.XPATH, ' //*[@id="matchStatsDuration"]')))
    element.click()


Tags: httpscom网站htmldriverselenium错误element
1条回答
网友
1楼 · 发布于 2024-04-26 02:47:34

下面是我将遵循的从这个列表中选择项目的简单方法。你知道吗

# select Month from the list.
element = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH, "//select[@id='matchStatsDuration']/option[.='Month']")))
element.location_once_scrolled_into_view
element.click()

通过这种方式,我不必担心重叠的顶部菜单,它阻碍了对列表元素的单击。你知道吗

相关问题 更多 >