Showing posts with label Webdriver. Show all posts
Showing posts with label Webdriver. Show all posts

December 2, 2021

Selenium Interview Questions on Textbox Part -2

December 02, 2021 21
Selenium Interview Questions on Textbox

1. How to get text in textbox?
2. How to get attributes like size, placeholder of text box?
We have to use getAttribute command to get attrubte values of textbox.
driver.findElement(locator).getAttribute("value"); -- for text in textbox 
driver.findElement(locator).getAttribute("attributeName"); -- For any attribute





January 11, 2020

Execute scripts on Edge Browser

January 11, 2020 2
In this post we will see how to execute webdriver scripts in EDGE Browser.

For other browsers like google chrome and firefox we need to download corresponding exe files and need to set system path.

If you are using latest version of edge i.e 18+ then the set up is little bit different.

Check Edge Version : 
Launch edge browser
Right hand top corner you see 3 dots.
Click on 3 dots and click on Settings
At the end you can see browser information. Mine is Microsift Edge HTML 18.1863

Download exe file:
Edge browser exe files are available in below path
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads

If your edge version is less than 18 then straight away download corresponding exe file and in your webdriver script need to set the system property like below.


If your edge version is 18 then need to perform belwo steps.

Below command should be executed in an elevated command prompt.

DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0

Elevated command prompt is nothing but need to launch your command prompt as admin.

Once you execute the command it will download MicrosoftWebDriver.exe file under C:\Windows\System32 folder.

Thats it...you can execute your scripts in Edge browser. no need to set up any path.

Below is the sample code:






Video is available here:


October 2, 2018

Automatic download and management of Selenium WebDriver binaries (Driver.exe files)

October 02, 2018 14
In this post we will see how to avoid downloading driver.exe file and setpath for browser binary.

As you guys already know in order to use chrome, firefox or edge browsers, first we need to download a binary file (driver.exe) and need to set path which allows Webdriver to handle browsers.



Below is example how to set path:


By adding a small dependency in your POM.xml (Assuming you are using maven project) we can avoid downloading binary files and set path. In addition, we have to check manually when new versions of the binaries are released. WebDriverManager will do this job for us automatically


How it works:

WebDriver Manager actually gets your browser version and download the compatible browser binary by itself to make you run your code without interruption.

So now, rather than setting the browser binaries, you just need to add below line of code and you’re done


The line WebDriverManager.chromedriver().setup(); WebDriverManager does magic for you:

  1. It checks for the latest version of the WebDriver binary.
  2. It downloads the WebDriver binary if it’s not present on your system.
  3. It exports the required WebDriver Java environment variables needed by Selenium
By default downloaded binary files (driver.exe) files will be stored in .m2 folder. By using below commands you can get the downloaded version and path of binary file.


Below is sample code:



Video is available here: