VBA-使用ng-click进行网络抓取 [英] Vba - webscraping using ng-click
本文介绍了VBA-使用ng-click进行网络抓取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Selenium,我希望能够单击以下内容
I am using Selenium and I would like to be able to click on the following
<a ng-click="download()">download</a>'
这是一个"a"标签.我不确定代码如何单击进入带有ng-click的'a'标签.
This is an 'a' tag. I am not sure how the code would be like to click onto an 'a' tag that has got ng-click in it.
Dim d As WebDriver
Set d = New ChromeDriver
Const URL = "url of the website - not public"
With d
.Start "Chrome"
.get URL
.Window.Maximize
.FindElementById("Search").SendKeys "information to search"
.Wait 1000
.FindElementById("Submit").Click
.Wait 1000
'then I need to click the following <a ng-click="download()">download</a>
End With
我所缺少的唯一步骤是能够单击最后一点.谢谢您的提前帮助:)
Only step I am missing is to be able to click on that last bit. Thank you for the help in advance :)
推荐答案
所需的元素是 Angular 元素需要为 elementToBeClickable 引入 WebDriverWait ,您可以使用以下
The desired element is an Angular element you need to induce WebDriverWait for the elementToBeClickable and you can use either of the following Locator Strategies:
-
使用
FindElementByCss
:
d.FindElementByCss("a[ng-click^='download']").click
使用 FindElementByXPath
:
d.FindElementByXPath("//a[starts-with(@ng-click, 'download') and text()='download']").click
这篇关于VBA-使用ng-click进行网络抓取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文