Vba Selenium:检查源代码中是否存在html标记 [英] Vba Selenium: Check if html tag is present in the source code
问题描述
这是我的问题,我有一个使用硒的Vba代码,该代码循环了很多网址.我需要验证是否存在一个标签,如果需要的话,我接下来需要继续执行代码,问题是我刚刚开始使用硒,并且我不知道如何验证给定标签是否存在.源代码.
This is my issue, I have a Vba code using selenium that loops trough a lot of urls. I need to validate if one tag is present, and if it is I need the code to resume next, the problems is that I just started to use selenium, and I don't know how to validate if the tag is present in a given source code.
这是标签:
<a class="fontdn" id="fontdn" href="#" title="Zoom Out (Key: -)">Zoom Out (Key: -)</a>
这是我到目前为止拥有的Vba-Selenium代码,它假定返回具有此id的元素数量,但是不起作用.
and this is the Vba-selenium code I have so far, this suppose to return the number of elements with this id but doesn't work.
If IE.findElementsByTitle("Zoom Out (Key: -)").Size() > 0 Then Exit For
推荐答案
我检查了Excel VBA的包装,但在代码中没有看到findElementsByTitle
:
I checked the wrapper for Excel VBA, I don't see a findElementsByTitle
in the code: https://code.google.com/p/selenium-vba/source/browse/trunk/wrapper/WebElement.cs
您应该可以使用:
If IE.findElementsByClassName("fontdn").Size() > 0 Then Exit For
修改
我仔细查看了包装器源,findElementsByClassName
返回了一个数组.据我所知,Excel VBA阵列使用Length
而不是Size()
.
I looked through the wrapper source some more, findElementsByClassName
returns an array. Excel VBA array uses Length
, not Size()
, from what I can tell.
也许是吗?
If IE.findElementsByClassName("fontdn").Length > 0 Then Exit For
这篇关于Vba Selenium:检查源代码中是否存在html标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!