0

I am trying to convert an Excel macro that currently uses Internet Explorer and use the following line of code to extract the web page’s <body> text

x = .Document.DocumentElement.InnerText

Using the Selenium demo, I am able to produce a jpg of the page with Chrome & IE, but Firefox just loads a blank page and IE64 & Edge don’t work on Windows 10.

I have been unable to find the proper VBA command with Selenium to copy the body text to variable ”x”. I only want to read it.

I am trying to do this to make my macro browser independent.

The macro is for my use only.

Jim

1 Answer 1

0

You are not making it browser agnostic. You are simply widening the choice of browser to those supported via selenium basic. This brings some problems of its own which you are noticing.

  1. Folders containing the drivers must be on the environmental path or the path passed to selenium webdriver as an argument.
  2. You should use the latest Chrome browser and Chrome driver
  3. You cannot use the latest FireFox browser and driver. It is not supported. I think you need FF v.46.0.1.
  4. If using IE then zoom must be to 100%.
  5. I suggest browsing the issues pages of Github for further known issues
  6. Heuristically, I have heard some banter about problems with Windows 10 and Selenium Basic - would be interested to know if anyone has got this working as I am not on that version.

Review the examples.xlsm provided by selenium basic GitHub site to see which other browsers are supported (e.g. Opera, PhantomJS, FirefoxLight,CEF).

With Chrome you can get the body text with this:

Option Explicit 
Public Sub GetInfo()
    Dim d As WebDriver, s As String
    Set d = New ChromeDriver
    Const URL = "https://www.neutrinoapi.com/api/api-examples/python/"

    With d
        .Start "Chrome"
        .get URL
        s = .FindElementByTag("body").Text
        Debug.Print s
        .Quit
    End With
End Sub

Other info: https://stackoverflow.com/a/52294259/6241235

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks I will give it a try

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.