11/4/2019 Selenium Webdriver Testing Tutorial
Sep 21, 2019 Selenium is a free open source testing tool which caters different testing needs. This tutorial cover Selenium webdriver, IDE, TesNG. Following course will make you Selenium pro. Tutorials are designed for beginners with little or no automation experience. Aug 21, 2019 In this tutorial, we tried to make you acquainted with Selenium WebDriver by outlining its architecture, features and limitations. Here are the cruxes of this article. Selenium suite is comprised of 4 basic components; Selenium IDE, Selenium RC, WebDriver, Selenium Grid. WebDriver allows a user to perform web-based automation testing. This Edureka Selenium tutorial video (Selenium Blog Series: on 'How to Write & Run a Test Case in Selenium' will give you an introduction to automated software testing tool. Selenium Webdriver Tutorial by using JAVA and TestNG article is a perfect starting point for Selenium Test Automation with TestNG.In this article, I will explain how to start to Selenium Webdriver with JAVA and TestNG step by step.If you want to start Selenium with JUnit, you can also read this article. Let’s start to Selenium Automation with TestNG and JAVA.
Selenium is one of the most widely used open source Web UI (User Interface) automation testing suite. Our Selenium tutorial includes all topics of Selenium such as Features, Selenium vs QTP, Selenium Tool Suits, Selenium IDE, Selenium IDE Locating Strategies, Selenium WebDriver, WebDriver Features, WebDriver vs RC, WebDriver Installation, etc. Selenium Webdriver Tutorial by using JAVA and TestNG article is a perfect starting point for Selenium Test Automation with TestNG.In this article, I will explain how to start to Selenium Webdriver with JAVA and TestNG step by step.
![]()
WebDriver is a tool for automating testing web applications. It is popularly known as Selenium 2.0. WebDriver uses a different underlying framework, while Selenium RC uses JavaScript Selenium-Core embedded within the browser which has got some limitations. WebDriver interacts directly with the browser without any intermediary, unlike Selenium RC that depends on a server. It is used in the following context −
Architecture
WebDriver is best explained with a simple architecture diagram as shown below.
Selenium RC Vs WebDriver
Scripting using WebDriver
Let us understand how to work with WebDriver. For demonstration, we would use https://www.calculator.net/. We will perform a 'Percent Calculator' which is located under 'Math Calculator'. We have already downloaded the required WebDriver JAR's. Refer the chapter 'Environmental Setup' for details.
Step 1 − Launch 'Eclipse' from the Extracted Eclipse folder.
Step 2 − Select the Workspace by clicking the 'Browse' button.
Step 3 − Now create a 'New Project' from 'File' menu.
Step 4 − Enter the Project Name and Click 'Next'.
Step 5 − Go to Libraries Tab and select all the JAR's that we have downloaded. Add reference to all the JAR's of Selenium WebDriver Library folder and also selenium-java-2.42.2.jar and selenium-java-2.42.2-srcs.jar.
Step 6 − The Package is created as shown below.
Step 7 − Now right-click on the package and select 'New' >> 'Class' to create a 'class'.
Step 8 − Now name the class and make it the main function.
Step 9 − The class outline is shown as below.
Step 10 − Now it is time to code. The following script is easier to understand, as it has comments embedded in it to explain the steps clearly. Please take a look at the chapter 'Locators' to understand how to capture object properties.
Step 11 − The output of the above script would be printed in Console.
Most Used Commands
The following table lists some of the most frequently used commands in WebDriver along with their syntax.
Selenium Overview:
Cave story english download. Selenium is an open-source, web Automation Testing tool that supports multiple browsers and multiple operating systems. It allows testers to use multiple programming languages such as Java, C#, Python, .Net, Ruby, PHP, and Perl for coding automated tests.
C # Overview:
C# is an object-oriented programming language derived from C++ and Java. C# allows developers to build applications using Visual Studio on .Net platform. The following are the key features of C#.
Basic Syntax of C #:
A program in C # need to contain the following sections
Example-
Below is a sample C# program to print the text 'Guru99' on the system console.
Explanation:
Set Up Visual Studio with Selenium WebDriver:
Visual Studio is an Integrated Development Environment (IDE) that is used by developers to build applications across multiple platforms such as Windows, Android, iOS and Cloud-based applications.
Step 1) Navigate to the URL https://www.visualstudio.com/downloads/ and Click on the 'Free download' button displayed on Visual Studio Community 2017 tab
Step 2) Open the exe downloaded. Click on 'Yes' if asked for Admin Rights.
Step 3) The below popup will appear. Click on 'Continue' button.
Files will be downloaded as shown in the popup below.
Step 4) In the next screen,
Select the checkboxes for
Click on 'Install.'
Wait for installation of each component to complete. Files are 16GB in size and will take time.
Step 5) The below pop up will be displayed. Click on 'Restart' button.
Step 6) Once the machine is restarted, search for 'Visual Studio 2017' on the start menu and click on the search result. The following popup will appear. Click on 'Not now, maybe later' link if you do not have an existing account.
Step 7) In the next screen,
Step 8) Visual Studio 'Get Started' screen will appear.
Create a new project in Visual Studio:
Step 1) In the File Menu, Click New > Project
Step 2) In the next screen,
Step 3) The below screen will be displayed once the project is successfully created.
Set up Visual Studio with Selenium WebDriver:
Step 1) Navigate to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution
Step 2) In the next screen
Step 3) Click on 'OK' button in the pop-up screen
Step 4) The below message will be displayed once the package is successfully installed.
NUnit Framework: Overview
NUnit is the Unit Testing framework supported by Visual Studio and Selenium WebDriver. NUnit is the most widely used Unit Testing framework for .Net applications. NUnit presents the test results in a readable format and allows a tester to debug the automated tests.
We need to install NUnit Framework and NUnit Test Adapter onto Visual Studio inorder to use it.
Steps to install NUnit Framework:
1. Navigate to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution
Step 2) In the next window
Step 3) The below popup will appear. Click on 'Ok' button.
Step 4) The below message will appear once the installation is complete.
Steps to download NUnit Test Adapter
Please note that the below steps work only for 32-bit machines. For 64-bit machines, you need to download the 'NUnit3 Test Adapter' by following the same process as mentioned below.
Step 1) Navigate to Tools ->NuGet Package Manager -> Manage NuGet Packages for Solution. In that screen,
Step 2) Click OK on the confirmation pop-up. Once install is done you will see the following message-
Selenium and NUnit framework:
Integration of selenium with NUnit framework allows a tester to differentiate between various test classes. NUnit also allows testers to use annotations such as SetUp, Test, and TearDown to perform actions before and after running the test.
NUnit framework can be integrated with Selenium by creating a NUnit test class and running the test class using NUnit framework.
The below are the steps needed to create and run a test class using NUnit framework.
Steps to create a NUnit Test class in Selenium:
Step 1) In the Solution Explorer, Right click on project > Add > Class
Step 2) Class creation window will appear.
Step 3) The below screen will appear.
Step 4) Add the following code to the created class. Please note that you need to specify the location of 'chromdriver.exe' file during chrome driver initialization.
Step 4) Click on 'Build' -> 'Build Solution'
NOTE: You may get an error like 'Does not contain a static 'main' method suitable for an entry point' when you build
To resolve this Got to Project > Properties and change Output Type to 'Class Library.' The default is 'Console Application.'
Step 5) Once the build is successful, we need to open the Test Explorer window. Click on Test -> Windows -> Test Explorer
Step 6) Test Explorer window opens with the list of available tests. Right-click on Test Explorer and select Run Selected Tests
Step 7) Selenium must open the browser with specified URL and close the browser. Test case status will be changed to 'Pass' on the Test Explorer window.
Selenium WebDriver Commands in C#:
C# uses the interface 'IWebDriver' for browser interactions. The following are the category of commands available in C#.
Selenium Webdriver Testing Tutorial For Beginners
Let's study them one by one
Browser commands:The following are the list of browser commands available in C#.
Webelement Commands:Selenium Webdriver Tutorial Guru99
A Webelement represents all the elements on a web page. They are represented by HTML tags. Each of the buttons, textboxes, links, images, tables, and frames fall under Webelements. Operations on web elements can be triggered using the IWebelement interface. To interact with a Webelement, we need to find the element on the webpage and then perform operations on it. Tools like Firebug and Firepath can be used to identify the Xpath of Webelement.
The following are the list of Webelement commands available in C#.
Dropdown Commands:
Dropdown operations in C# can be achieved using the SelectElement class.
The following are the various dropdown operations available in C#.
Code SamplesExample 1: Click on a link using XPATH Locator:
Test Scenario:
Example 2: Entering data into TextBox and Click on a button using XPATH locator:
Test Scenario:
Example 3: Entering data into TextBox and Click on a button using CSS locator:
Test Scenario:
Example 4: Select a value in the dropdown:
Test Scenario:
Selenium Remote WebdriverSummary:
This article is contributed by Sneha Gudapati
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |