gpt4 book ai didi

python - 滚动到 python selenium 中的特定元素

转载 作者:行者123 更新时间:2023-12-01 01:21:05 30 4
gpt4 key购买 nike

我试图向下滚动到 python 中的特定元素,但它不起作用。有任何改进建议!

Loc_Hours =self.driver.find_element_by_xpath("/html[1]/body[1]/div[1]/div[2]/div[1]/div[5]/div[1]/div[1]/div[1]/div[2]/div[1]/p[1]")
self.driver.execute_script("return arguments[0].scrollIntoView();", Loc_Hours)
Loc_Hours.text()
self.driver.execute_script("window.scrollBy(0, -150);")

最佳答案

你能试试这个吗:

from selenium.webdriver.common.action_chains import ActionChains

Loc_Hours = self.driver.find_element_by_xpath("/html[1]/body[1]/div[1]/div[2]/div[1]/div[5]/div[1]/div[1]/div[1]/div[2]/div[1]/p[1]")
ActionChains(self.driver).move_to_element(Loc_Hours)).perform()

关于python - 滚动到 python selenium 中的特定元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53828776/

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