使用firefox点击下一页的Vba代码

时间:2017-09-19 06:21:20

标签: vba firefox

我在此代码的帮助下有vba代码我可以使用Internet Explorer点击网站的下一页,但我希望这段代码可以在firefox中使用。

请找到以下代码



Dim lis As IHTMLElementCollection
Dim nextLi As HTMLLIElement, n As Long
Set lis = IE.document.getElementsByTagName("LI")
Set nextLi = Nothing
n = 0
While n < lis.Length And nextLi Is Nothing
If lis(n).innerText = "Next" Then Set nextLi = lis(n)
n = n + 1
Wend
If Not nextLi Is Nothing Then
nextLi.Click
End If
&#13;
&#13;
&#13;

我试过firefox的代码

&#13;
&#13;
Sub test() 
Dim driver As New Selenium.FirefoxDriver
Dim lis As IHTMLElementCollection 
Dim nextLi As HTMLLIElement, n As Long 
driver.Get "url" 
driver.Timeouts.Server = 120000 
driver.Window.Maximize 
Dim lis As IHTMLElementCollection
Dim nextLi As HTMLLIElement, n As Long
Set lis = driver.findElementsByTagName("LI")
Set nextLi = Nothing
n = 0
While n < lis.Length And nextLi Is Nothing
If lis(n).innerText = "Next" Then Set nextLi = lis(n)
n = n + 1
Wend
If Not nextLi Is Nothing Then
nextLi.Click
End If
End Sub
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

您使用的SeleniumBasic开放代码无法处理FireFox 47及更新版本。

通过询问Selenium团队,还没有计划更新SeleniumBasic添加新的FirefoxDriver(现在称为GeckoDriver)。

无法在代码后使用VBA和Selenium更新的FireFox版本。