Selenium-rc:有没有办法发送请求缓冲区
假设我有一个链接列表,想要随机单击一个链接:
<div id="divA">
<a> first link </a>
<a> second link </a>
...
</div>
这不是最聪明的方法(如果您有更好的解决方案,请告诉我),但我目前所做的(大致)是:
l = []
for i in range(numOfLinks):
xpath = '//div[@id="divA"]/a[%d]'%i
txt = sel.getText(xpath)
l.append(xpath, txt)
xpath,linkName = random.choice(l)
sel.click(xpath)
主要问题该解决方案的主要特点是它向 selenium 发送许多请求。我的问题是:有没有办法将所有这些请求保存在缓冲区中并立即发送?
Lets say I have a list of links and want to click a link at random:
<div id="divA">
<a> first link </a>
<a> second link </a>
...
</div>
It isn't the smartest of ways (and if you have a better solution please tell me) but what I currently do is (roughly):
l = []
for i in range(numOfLinks):
xpath = '//div[@id="divA"]/a[%d]'%i
txt = sel.getText(xpath)
l.append(xpath, txt)
xpath,linkName = random.choice(l)
sel.click(xpath)
The main problem of this solution is that it sends many requests to selenium. My question is: is there a way of saving all these requests in a buffer and sending them at once?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你用文字做任何事吗?
上面的代码将始终单击随机链接,而不必每次都获取链接的文本。
are you using the text for anything?
The code above will always click on a random link without having to get the text of the link each time.