javascript - 通过 execute_script 调用的 scrollBy() 不适用于使用 Selenium 和 Python 的 chrome 商店页面

标签 javascript python selenium google-chrome js-scrollby

我将 selenium 与 python 3 和 Chrome 驱动程序一起使用。我正在尝试在 Chrome 商店 URL 中执行滚动。

这个:https://chrome.google.com/webstore/detail/online-game-zone-new-tab/abalcghoakdcaalbfadaacmapphamklh

无论我怎样尝试,网站都无法滚动。尝试运行“window.scrollBy”和“window.scrollTo”。 尝试先点击“正文”,然后点击其他元素 - 没有。

当前代码:

driver.maximize_window()
driver.get(url)
time.sleep(4)
driver.execute_script("window.scrollBy(0, 500)")

可能是什么问题?我不想发送“向下”键或“向下翻页”,因为我认为我需要更加精确。

最佳答案

将元素滚动到 View 中似乎在该网页上运行良好。这是一个例子:

footer=driver.find_element_by_class_name('e-f-ra-gj')
driver.execute_script("arguments[0].scrollIntoView()", footer)

关于javascript - 通过 execute_script 调用的 scrollBy() 不适用于使用 Selenium 和 Python 的 chrome 商店页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61892553/

相关文章:

javascript - 使传单 map 移动响应

javascript - ‘node.js’: Does it need to be run a server?

javascript - 如何在 ASP.NET MVC 应用程序中组织 JavaScript 代码

python - 如何重写这个字典定义以使 PyCharm 不发出警告?

python - 如何验证文本字段是否具有我输入的值?

python - 套接字错误 : [Errno 54] Connection reset by peer Selenium-python

javascript - 动态创建的模态不起作用

python - 如何在python中获取5分钟前的时间

python - 查找值小于/大于另一个数据帧的行

java - 从 tr 标签中找到一个复选框并在 Selenium(java) 中选择它