我试图让程序在一个特定的div
中滚动,以加载其中包含的所有必需元素。据我所知,JavaScript代码是正确的,但它一直给我这个错误:
selenium.common.exceptions.JavascriptException: Message: TypeError: document.getElementsByClassName(...)[0] is undefined
这是错误所指的行:
bot.execute_script("document.getElementsByClassName('uiScrollableAreaBody')[0].scrollTo(0,1000)")
似乎脚本正在尝试在元素加载到页面之前获取该元素。尝试使用显式等待或
time.sleep(x)
(我个人更喜欢第一种方法,这样脚本就不会停止x秒这是伪代码
相关问题 更多 >
编程相关推荐