在 Browserstack 中使用 Python Selenium 无限滚动
Infinite Scroll Up-Down with Python Selenium in Browserstack
这是我的 selenium 测试代码,但我需要无限上下滚动。
我做了一些研究,但我总是遇到这个错误;
STOP SESSION BROWSERSTACK_IDLE_TIMEOUT
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
desired_cap = {
'browser': 'Firefox',
'browser_version': '77.0',
'os': 'Windows',
'os_version': '10',
'resolution': '1024x768',
'name': 'Bstack-[Python] Sample Test'
}
driver = webdriver.Remote(
command_executor='https://something',
desired_capabilities=desired_cap)
driver.get("http://something")
我认为任何无限向上和向下滚动代码都可以修复此错误。
Browserstack 默认超时为 90 秒,以防您没有明确说明超时持续时间。
设置超时的能力是:
'browserstack.idleTimeout': 300
该值最多可达 300
秒。您可以在此处查看功能页面:https://www.browserstack.com/automate/capabilities
我找到了一篇很好的文章,您可以阅读这篇文章来实现无限滚动:
https://dev.to/hellomrspaceman/python-selenium-infinite-scrolling-3o12
它的工作原理是滚动整个页面高度并在进一步滚动之前等待一小段时间。
这是我的 selenium 测试代码,但我需要无限上下滚动。 我做了一些研究,但我总是遇到这个错误;
STOP SESSION BROWSERSTACK_IDLE_TIMEOUT
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
desired_cap = {
'browser': 'Firefox',
'browser_version': '77.0',
'os': 'Windows',
'os_version': '10',
'resolution': '1024x768',
'name': 'Bstack-[Python] Sample Test'
}
driver = webdriver.Remote(
command_executor='https://something',
desired_capabilities=desired_cap)
driver.get("http://something")
我认为任何无限向上和向下滚动代码都可以修复此错误。
Browserstack 默认超时为 90 秒,以防您没有明确说明超时持续时间。
设置超时的能力是:
'browserstack.idleTimeout': 300
该值最多可达 300
秒。您可以在此处查看功能页面:https://www.browserstack.com/automate/capabilities
我找到了一篇很好的文章,您可以阅读这篇文章来实现无限滚动:
https://dev.to/hellomrspaceman/python-selenium-infinite-scrolling-3o12
它的工作原理是滚动整个页面高度并在进一步滚动之前等待一小段时间。