How Can I Use Selenium in Excel Without SeleniumBasic? - excel

I created a tool on the job using Excel, VBA and SeleniumBasic to drive Chrome or Edge to go to a company web page and enter some data. The tool works well, but when I requested that it be distributed to a wider audience, I was told that although Selenium is approved for use on company networks, SeleniumBasic is not.
So my question is, is it possible/easy to drive Selenium directly with VBA and avoid having to use SeleniumBasic? The approval process for FOSS is not easy and would take too long, so I think I have to find a workaround.

Related

Get already opened Edge (not IE) browser window(s) and scrape contents

I used to be able to find all open IE windows via VBA and was able to access one of the already-opened page's contents in Excel with the objShell object mechanism. I didn't--and don't need--direct "control" (automation) of the browser in terms of pushing buttons, opening urls, etc.
I know automation of Edge is not possible just using VBA, but is there any ability to simply 1.) get a list of MS EDGE open windows and 2.) retrieve the elements within a given (already opened) window without resorting to downloading drivers and utilities like Selenium?
As Tim Williams had informed you there is no COM interface available for the Edge browser.
Microsoft has not provided any way to automate the Edge browser using VBA automation.
So, there is no way to fetch the already opened instance of the Edge browser and retrieve elements with the help of VBA.
I suggest you use the officially recommended way Selenium Web Driver to automate the Edge browser.
I have seen that you want to avoid the Selenium Web Driver approach but at present, this is the only way available to automate the Edge browser.
If you are having any issues with the Selenium Web Driver approach then you can inform us about it. We can try to provide suggestions for it.
Thanks for your understanding.
Please note: I'm the author of this software
You can connect to active instances of Edge with IE mode using Internet Controls for Edge: https://pomio.dk/internet-controls-for-edge/.
Internet Controls for Edge is a COM component and it exposes the same APIs as Microsoft Internet Controls (for Internet Explorer), so if you've already created some automations of Internet Explorer (using Microsoft Internet Controls), then it should be straight forward to move to Internet Controls for Edge.

Upgrading From IE to EDGE

I need VBA Code translation for Edge.
I’m in a Window10/Excel 16 environment. I have been using Internet Explorer (IE) when I scrape data from websites.
Now, I am needing to upgrade to Microsoft Edge. I am having to translate some code and I am finding I need some help.
I used to call the URL https://www.azblue.com/individualsandfamilies/ using “IE.navigate”. Ex:
IE.navigate "https://www.azblue.com/individualsandfamilies/"
But, what I cannot figure out is how to use these other lines of Code with Edge. Here are a 3 lines of code (disjointed) that I use often and need to know the syntax translation for Edge:
IE.document.getElementById("lockedcontent_0_maincolumn_2_twocolumn2fb4d204091d44aa08196ef423877fd9f_0_ToolbarUsernameControl").Focus
IE.document.getElementById("lockedcontent_0_maincolumn_2_twocolumn2fb4d204091d44aa08196ef423877fd9f_0_ToolbarUsernameControl").Value = "MyUserName"
IE.document.Focus
Of course, any help is greatly appreciated
Thanks!
Microsoft Edge browser doesn't support the COM automation interface that used in VBA. If you want to automate Microsoft Edge, you should use WebDriver.
To get started using WebDriver, you will need to download a testing framework of your choice along with an appropriate language binding and the MicrosoftWebDriver server.
We usually use Selenium and you could download the language binding in this page. At the same time, you could download Microsof Edge WebDriver in this page.
Reference link: Will Microsoft Edge support COM automation (InternetExplorer object)?

data extraction from google chrome

I want to get table data from money control website. http://www.moneycontrol.com/financials/infosys/results/consolidated-quarterly-results/IT. I want to use google chrome to open this link and then click on previous years link and get that table too along with the table on that page. I need to click previous years as the url even after clicking previous years remains the same and I cannot directly navigate to it. It is easy with internet explorer but I cannot use it. If there is any other method other than having to click on the link please tell.
Without using a third party library it is only possible to use the Internet Explorer object.
To automate Google Chrome you can try to use Selenium VBA. It's a COM library which creates a Windows COM wrapper for Selenium.
http://florentbr.github.io/SeleniumBasic/
In Google Chrome you have to install a plugin, which helps executing the VBA commands in Chrome.
Download page: http://www.seleniumhq.org/download/

Without using webdriver add-in how to execute the SeleniumWrapper.WebDriver used excel macro

I have created an excel vba macro code using selenium webdriver.
"Dim selenium As New SeleniumWrapper.WebDriver".
It works well in my system as I have used "SeleniumWrapperSetup-1.0.17.0" to create the macro. But I cannot ask my whole team to install SeleniumWrapperSetup-1.0.17.0 as business wont accept installing the same in all my team members systems(around 200).
Is there a way where I can execute the selenium based macro(Helps to fetch data from the webpage in Chrome browser) without installing the seleniumWrapper?
No matter what flavor of Selenium you use, you will have to at least distribute some files. If it helps people get the job done more quickly, why wouldn't the business support this?
Have you considered writing the tool in C#, compiling it into an EXE, and the distributing it with the Selenium dlls? It will avoid installation but you will still have to distribute files.
Another option is to write the script in Selenium IDE and distribute the script. Everyone would have to install the Selenium IDE (Firefox browser plugin).
If your team members are somewhat web savvy, you could write the scraper in Javascript and give them a file that they could run as a Chrome snippet in their browser... no installs necessary.

Automate right click save as in IE, Chrome and Firefox?

Does anybody know a way I can automate the right click and save as actions for IE, Chrome and Firefox?
I am doing some selenium work using Maven and need to be able to download some files but I am unable to do this as the save as windows cannot (to my knowledge) be automated by Selenium as they are OS dialogs.
I disagree with Bob, Bill and the author of the article that is linked to in the other answer.
Downloads can be automated. The downloaded file can be meaningfully verified. In simplest case you can compare the contents of downloaded file with an existing exemplary file.
(Disclaimer: the next paragraph is about a tool which I am affiliated with).
For example if you use RIATest for automation you can automate the right click, then automate the OS dialog, then wait until the download is finished and verify the content of the downloaded file.

Resources