【发布时间】:2018-10-18 16:02:04
【问题描述】:
我在 vba 中编写了一个与 selenium 相关的脚本,以在某些 torrent 站点中启动搜索。我的脚本运行良好,但问题是我必须在脚本中使用hardcoded delay 才能使其成功。我现在想做的是通过从我的脚本中剔除硬编码延迟来使用某个循环或任何一种循环来检查所需元素的可用性。对此的任何帮助将不胜感激。
这是我目前的尝试(工作中的一个):
Sub SearchItem()
With New ChromeDriver
.get "https://torrentz2.eu/"
Application.Wait Now + TimeValue("00:00:10") ''I wish to shake this hardcoded delay off
.FindElementByCss("#thesearchbox").SendKeys ("Udemy")
.FindElementByCss("#thesearchbutton").Click
End With
End Sub
参考添加:
Selenium Type Library
【问题讨论】:
-
见:stackoverflow.com/questions/36590274/…。看起来您可以在那里尝试的方法很少。
-
感谢@Ryan Wildry 的评论。问题是
explicit wait在与 selenium 结合使用其他语言时有一些选项,但在vba的情况下,我怀疑是否有任何选项。至少我找不到任何地方。
标签: vba excel selenium web-scraping selenium-chromedriver