How to code MS Edge IE Mode on VBA using SeleniumBasic - vba

I am using Selenium Basic to automate MS Edge.
I would like to be able to open a url on MS Edge using IE Mode. I found that there is an IEDriverServer.exe that we can use to run urls on MS Edge IE Mode but there is no example how to use it on VBA.
Can someone help me how to properly put it in my code?
Dim driver As New WebDriver
Set driver = New EdgeDriver
driver.Get ("https://google.com")
driver.Refresh
Thanks.

Please refer to https://github.com/florentbr/SeleniumBasic/releases/tag/v2.0.9.0
Once you install Selenium Basic exe on your machine, you will get lot of ready examples with vbscript at installation location.
Also make sure to download latest edge driver and put in installation location by renaming as previous.
Sample code
Set driver = CreateObject("Selenium.EdgeDriver")
driver.Get "edge://settings/defaultBrowser"
driver.Window.Maximize
driver.FindElementByXPath(....<add xpath here>...)
' add required UI component action & xpath for the same.
driver.Quit

Related

Downloading a file in headless ChromeDriver with SeleniumBasic

I am trying to download files by clicking a button. This works fine as long as my ChromeDriver is not in headless mode. Once I tested the macro with ChromeDriver in headless mode, I realized that nothing was being downloaded. I researched the issue and found out that it was a security measure. There are suggested work-arounds for Python, however I was not able to translate the code into VBA. I am using SeleniumBasic.
What I want is to be able to download files to the Environ("userprofile") & "\Downloads\" folder once I click a download button, just like I do when the browser is not in headless mode. Thank you all in advance.
Notes:
I call the driver in headless mode using driver.AddArgument "--headless"
I could not provide the URL I am using as this is a long macro requiring login etc. but as far as I understand, the issue should be reproducible in any download scenario involving a headless ChromeDriver.
I am using the most recent SeleniumBasic v2.0.9.0 and the ChromeDriver version 75.0.3770.140

How do I make Internet Explorer driver invisible using Selenium and VB?

I am using Selenium WebDriver to make some automations, using chrome I can use the headless argument to hide it, but I don't know the argument to hide the Internet Explorer.
Dim driver As New ChromeDriver
driver.AddArgument ("headless")
Dim driver As New IEDriver
driver.AddArgument ("?????????????????????")
Library used - A Selenium based browser automation framework for VB.Net, VBA and VBScript
Based on my searching results, it looks like Internet Explorer does not support Headless mode.
As a work around, you can use trifleJS.
It can emulate some IE versions in a headless mode.
References:
(1) How to Set capability for IE browser to run in Headless mode
(2) TrifleJS

Trying to Automate Chrome with Selenium VBA, automation error?

I am trying to data scrape from a website that is only compatible with Google Chrome. I want to scrape the info into an Excel file so I would like to use VBA to accomplish this.
This is my code.
Sub OpenGoogleChrome()
Dim driver As New WebDriver
driver.Start "chrome", "http://www.google.com"
driver.Get "/"
End Sub
I've tried several variations of this code but I get the same error:
I am just simply trying to open chrome through this automation process so I can utilize it to data scrape later.
I am using Chrome v69, the most recent version of Selenium Basic (2.0.9.0) and I've replaced the Selenium Basic ChromeDriver with the latest version (2.42).
These are my VBA references for my code:
Any help would be much appreciated.
EDIT: I'm using Windows 10 and I do have the necessary .Net framework.
SeleniumBasic requires .NET Framework 3.5. I had the same problem once and activating it on Turn Windows features on and off dialog solved the problem. It worth the try
I faced this error as well, but solved it after I install Selenium via administrator mode.

Accept downloads automatically in Selenium WebDriver using IEDriver

How I can accept downloads in Selenium using InternetExplorerDriver.
Now when click to download file, Save As Dialog appears and then WebDriver stop the work.
I try to search a capability to set this how in ChromeDriver is just only add chromedriver.AddUserProfilePreference("download.prompt_for_download", false);
but I not found.
I need when driver click in button to download, the download automatically start and save in any folder.
Sorry my bad question. I'm new here.
I don't have windows machine so i couldn't check this but try following article. There is a registry which you need to modify to get such behavior. Let me know if it works.
https://jwcooney.com/2014/03/31/remove-internet-explorer-open-or-save-popup/
found another thread discussing the same thing
https://superuser.com/questions/246553/how-to-disable-file-download-popup-in-internet-explorer

Robot Framework browser support

Has the robot framework support for IExplorer or only for Firefox and Chrome?
(If yes, how to configure it?)
Thanks!
Robot Framework does not, in itself, support any particular browser, so I am guessing you are referring to either SeleniumLibrary or Selenium2Library which use selenium and selenium 2 respectively. The browser support of these is well documented at seleniumhq and there is much support out there. It is recommended for new projects to use Selenium2Library as this will receive ongoing support.
Please check the driver compatiblity for browser.
You might have already known of IE driver.
Apart from that you also need to check Python version- Selenium2 version - IE Driver version - IE browser version compatibility.
In addition to #theheadofabroom 's answer, I should add that Internet Explorer does not play well with Robot Framework. Your test might not work for any number of reasons on IE while it may work just fine on FireFox and Chrome, but the most common is timing. IE is just slow enough that when Robot Framework goes to click on the next element, it searches the page for it, but it hasn't loaded in yet. As long as you have the Selenium webdriver for IE installed correctly and have written your Robot Framework code correctly, I'd recommend adding some Sleep keywords between actions to slow your code down and increase the probability that the element you want to click will load before Robot Framework searches the page for it. This is especially true if you're writing for Chrome and want to send it to either Firefox or IE.
Open Browser ${WEBAPPURL} ${BROWSER} is the keyword to open the browser.
For Firefox you can use firefox/ff instead of ${BROWSER}
For Google Chrome you can use googlechrome/gc/chrome instead of ${BROWSER}
For Internet Explorer you can use internetexplorer/ie instead of
${BROWSER}
For Firefox you don't need any driver but IE and Chrome you need to install the drivers
You can find the installers in and info here for Chrome and here for IE
Download IEdriver exe from here and put this exe file in Scripts folder of your Python installation directory. For eg, in my case it is C:\Python27\Scripts.
Ride will now launch IE for you.
Robot class supports keyboard inputs regardless of the browser. It is a class from the java.awt package and not specific to any browser. It is used in automation for performing operations on the web browser(stand alone application) in which a web-page is being automated
Note that it cannot perform operations directly on the web browser as it's a stand alone application, but can make use of keyboard shortcuts to indirectly perform the operation.
For example, if you want to open a new tab in a browser, you can use the Robot class to press Ctrl+t instead of trying to click on the new tab.
Code to use it to open a new tab in your program
Webdriver driver = new ChromeDriver(); //FirefoxDriver(), IntrrnetExplorerDriver();
driver.get("......");
//code goes here
//to open a new tab
Robot rob = new Robot();
rob.keyPress(Keys.VK_CTRL);
rob.keyPress(Keys.VK_t);
rob.keyRelease(Keys.VK_CTRL);
rob.keyRelease(Keys.VK_t);
//itetator to switch between the tabs