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

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

Related

How to code MS Edge IE Mode on VBA using SeleniumBasic

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

How to click chrome extension using selenium webdriver java?

I am able to load a chrome extension through CRX file and successfully add it to the chrome with selenium webdriver using java with Chrome Options, can anyone tell me how to automate to click the extension once it added to the chrome.
Every time i have to click manually on the extension for the further process of automation.
Not sure how you are doing it. Try loading the extension using ChromeOptions, it loads the browser with extension and there is no need to click any button manually
ChromeOptions options = new ChromeOptions();
//Adding Chrome extension
options.addExtensions(new File("Chrome extension - crx file path"));
options.addArguments("--start-maximized");
options.addArguments("--test-type");
System.setProperty("webdriver.chrome.driver", "path to/chromedriver.exe");
driver = new ChromeDriver(options);
Just FYI - handling OS level controls is out of reach of Selenium.
To handle OS level controls you can use AutoIT or LDTP.
Personally I prefer LDTP for smaller interaction as it gives seamless experience and is platform independent - https://github.com/ldtp/cobra
You can also try Pywinauto, a python library. With pywinauto you write the code to handle the OS level control and call this python script from Java code. For most of the tools you need to install their executables but for Pywinauto you only need Python to be installed which is approved to use in most of the organizations. For basic pywinauto script you need not learn the language.
Refer https://pywinauto.readthedocs.io/en/latest/

Detecting angularJS elements in IE11 browser using selenium takes long time. How to resolve this?

I'm running selenium tests on IE 11 in angularJS application. It takes more than usual time to detect/select/validate elements while it works better in chrome.
Browser information : Internet explorer 11
Webdriver : IEdriverserver 32bit
selenium version: 3.14
You could try the following methods to make it faster when using selenium IE WebDriver:
Download the recommended 32 bit Windows IE WebDriver version 3.150.1
and latest stable version 3.141.59 of Selenium from this page.
Change your IE settings: Tools -> Internet Options -> Security, set Enable Protected Mode to the same value in all zones (all checked or all unchecked).
Instantiate your InterExplorerWeDriver class with the path of your IE WebDriver like this:
InternetExplorerDriver ieDiver = new InternetExplorerDriver(“Path to the 32 bit IEdriver”);
Add capability nativeEvents as false. Add capability requireWindowFocus as true.
Reference link:
(1) Very slow text entry on IEDriverServer
(2) Selenium WebDriver typing very slow in text field on IE browser

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

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