Selenium webdriver automated testing

Selenium webdriver automated testing

Web driver is tool used to test web applications across different browsers, on different parameters, by using different languages as per your convenience. Selenium is an open-source framework and Web driver used for automate testing of a web Application. It is a collection of different API’s and libraries. It is a web driver tool used to test the web application automatically to verify that it works expected.

It supports different browsers like Firefox, Chrome, Safari and Internet Explorer and also allows you to execute cross-browser testing. Different languages supported by web driver to write test script are Java, C#, .NET, PHP, Ruby etc.

Along with its advantage it also has a limitation that it can be used only
for web application testing i.e. we can’t test mobile application or any other application using selenium web driver except web application.

What is testing? 

It is a process to check that our web application is working as expected or not on different parameters like different browsers, by putting different values etc. there are basically two types of testing: Manual testing and Automated Testing.

Manual Testing vs. Automated Testing

Manual Testing is performed manually by testers where as automated testing is done by using web drivers.

Manual testing can have manual errors, sometimes you feel boredom and takes more time where as in automated testing you can pass various parameters in one time which makes it less time consuming and manual error can be resolved. Consider a scenario you have to test your website’s signup page which has following values like name, contact no, username and password. Now In manual testing tester will put different values inside these fields. One by one they have to put different combinations and have to run it on different browsers.

But in Automated testing you can test it on different browsers by just writing 2-4 lines of codes and also you can pass different values in a single code. Isn’t it great?

So the Question is how to use selenium for automated testing?

Here we are explaining the use of selenium using java language and net beans IDE with chrome driver. You can also use eclipse IDE or any other IDE according to your language preferences.

Prerequisites : You must have knowledge of java or any other programming language supported by web driver ,HTML, CSS, knowledge of Netbeans IDE.

STEP 1

First download selenium web driver and chrome driver from the given
link you can also use different browsers like Firefox, Opera etc.

https://www.selenium.dev/downloads/

https://chromedriver.chromium.org/downloads

unzip the above files.

STEP 2

Open netbeans IDE and create a new project by
Clicking on file-> new -> project -> select java -> name the project and here you go.

STEP 3

Go to project libraries and add the jar files of selenium web driver and chrome driver.

Go to your project -> libraries -> right click on libraries -> click on “add jar” option -> browse the location of your downloaded file and add all the files inside “lib” folder of web driver.

STEP 4

Create main Class, give a Suitable name. Now you have to write a test script here in netbeans if you are using other Web driver than chrome than you don’t have to write it.

To automate the test for a specific browser you need to download it. Here we are using chrome driver.

System.setProperty (String key, String path): now to help selenium web driver to identify the browser on which tests to be executed we write this method.
In “key” parameter you have to write “webdriver.chrome.driver”
And in “path” specify the path of your chrome_driver.exe file.
See the below image for more.

STEP 5

Create a reference of Web driver interface and pass the object of chrome driver in it , import all the required packages according to the image given below.

Now this driver object will fetch all the details from website.

Image: STEP-4 and STEP-5
Image: STEP-4 and STEP-5

STEP 6

Call get(“URL”) method using driver reference.

driver.get(“http://www.amazon.com”);

Copy the path of any website you want to open and paste it Inside it in above mentioned manner.

Also write a print statement to as check. Like

System.out.println(“Website opended Successfully !!”);

Now close the driver using close() method.

Driver.close();

Hurray !! you have Successfully Opened the website using chrome driver. Similarly by using various methods you can fetch any detail from website and perform automate testing.

How to test web application using selenium webdriver?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

code