gpt4 book ai didi

Python + Selenium : element not visible

转载 作者:行者123 更新时间:2023-11-30 22:24:08 25 4
gpt4 key购买 nike

这是网页--link 。我要爬行(波斯语)。当我要单击下一页按钮时遇到问题。 XPath 是:

nextpage = '//*[@id="ctl00_ContentPlaceHolder1_ASPxSplitter1_CallbackPaneldgd_dgd_DXPagerBottom"]/a[1]/img'
page = driver.find_element_by_xpath(nextpage)
page.click()

page.click()之后我收到以下错误:

selenium.common.exceptions.ElementNotVisibleException: Message: element not visible

有些答案说可能存在重复的XPath,但我在网页源中找不到这样的东西。

完整代码:

import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains


driver = webdriver.Chrome(executable_path='./chromedriver')
url = 'http://hmi.mrud.ir/sabaa/SABAA/Home/Default.aspx?strTownship=0101&g=false'
driver.get(url)
time.sleep(10)
nextpage = '//*[@id="ctl00_ContentPlaceHolder1_ASPxSplitter1_CallbackPaneldgd_dgd_DXPagerBottom"]/a[1]/img'
page = driver.find_element_by_xpath(nextpage)
page.click()

谢谢。

最佳答案

在单击元素之前使用以下命令:

driver.execute_script("arguments[0].scrollIntoView(true);", page)

这是滚动到元素。

希望对你有帮助!

关于Python + Selenium : element not visible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47905232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com