Excel Selenium VBA:driver.captureEntityRepageScreenshot.Copy

Excel Selenium VBA:driver.captureEntityRepageScreenshot.Copy,excel,vba,selenium,screenshot,Excel,Vba,Selenium,Screenshot,论坛新成员,Selenium VBA新成员。为我的无知提前道歉。 但是,我已经搜索过任何一个VBA版本,它可以捕获完整的页面元素,而不需要插件或使用Java 我希望尽可能简单地捕获一个完整的页面截图,然后将其从剪贴板粘贴到excel中的工作表中 到目前为止,我知道它可以改进,其中一些可能是不必要的,但我不知道为什么它在bot.TakeScreenshot.Copy运行时不起作用,但只捕获可见屏幕 Public Sub CommandButton1_Click() Dim bot As New

论坛新成员,Selenium VBA新成员。为我的无知提前道歉。 但是,我已经搜索过任何一个VBA版本,它可以捕获完整的页面元素,而不需要插件或使用Java

我希望尽可能简单地捕获一个完整的页面截图,然后将其从剪贴板粘贴到excel中的工作表中

到目前为止,我知道它可以改进,其中一些可能是不必要的,但我不知道为什么它在bot.TakeScreenshot.Copy运行时不起作用,但只捕获可见屏幕

Public Sub CommandButton1_Click()

Dim bot As New WebDriver, rng As Range
Set rng = Range(Worksheets("sheet1").Range("A2"), 
Worksheets("sheet1").Range("A2").End(xlDown))

'this loops through each href in cells navigating to the page unless the cell has end in it

For Each cell In rng
TextBox2.Text = ActiveCell.Text
TextBox3.Text = ActiveCell(1, 2).Text
If ActiveCell.Text = "End" Then
bot.Quit
Else
bot.Start "chrome", TextBox2.Text
bot.Window.Maximize
bot.Get "/"

'this takes a screenshot of each url in the loop and copys it

bot.captureEntirePageScreenshot.Copy

'bot.TakeScreenshot.Copy

'this creates a new sheet names it according the relavent test related to the url and pastes it in that newlt created sheet

ActiveWorkbook.Sheets.Add.Name = ActiveCell(1, 2).Text
ActiveSheet.PasteSpecial

'this goes back to the original sheet to continue with loop

Worksheets("sheet1").Select
ActiveCell.Offset(1, 0).Select

bot.Quit
End If
Next

End Sub

使用无头浏览器

这取自selenium附带的示例代码

在win7机器上。。。C:\Users\xxxx\AppData\Local\SeleniumBasic\Examples\VBScript

Option Explicit

Sub demoPhantomJSDriver()

    Dim aaa As Selenium.PhantomJSDriver
    Set aaa = New Selenium.PhantomJSDriver
    aaa.Get "https://stackoverflow.com/questions/tagged/vba?sort=newest&pageSize=50"
    aaa.Window.Maximize

    Dim bbb As Object
    Set bbb = aaa.TakeScreenshot
    bbb.ToExcel Range("h3")
    Set bbb = Nothing

End Sub

这就是驱动程序的局限性,您不能对itThanks@TarunLalwani做太多工作。是否有任何针对VBA的解决方案?我看到了Java替代选项。请给我指出Java替代选项ones@TarunLalwani一个ChromeJava浏览器,但不知道如何将ashot集成到VBA中-