• info@bugespy.com
  • Sales: +1 (855) 895-6781

What is Selenium?

Selenium is an automated, open-source testing tool that is used to validate web apps across various platforms and browsers. Testing can be done for various platforms such as Java, Python, Ruby, etc. The testing performed by selenium automated testing tools is referred to as selenium testing.

Selenium is not a single tool but it is a set of software in which every single part fulfills different testing requirements for its users. Those components are listed below:

  • WebDriver
  • Selenium Integrated Development Environment (IDE)
  • Selenium Remote Control (RC)
  • Selenium Grid

If you are looking for Automated Testing for your website or app then you can get our services at BugEspy.

Introduction of selenium IDE

Selenium IDE is the simplest framework in the selenium suite and should be learned first. It is a Browser plugin that a tester can easily install with the other plugins. Whereas, selenium IDE must be used only as a product prototyping tool due to the reason of its simplicity.

Introduction of Selenium Remote Control

For a long time Selenium Remote Control (RC) had been a flagship testing framework of the entire selenium project. It facilitates its user to perform tests for platforms that they prefer to use for automated web testing.

The platforms supported by selenium RC are stated below:

  1. Java
  2. C#
  3. PHP
  4. Python
  5. Perl
  6. Ruby

Introduction of Selenium WebDriver.

“Selenium webDriver is an automated framework which provides its users to execute testing process against various browsers, not only Chrome, Firefox (unlike Selenium IDE).”

  • The utilization of a specific programming language platform to create your testing script is another feature provided by WebDriver.
  • The conditional operations like switch-case or then-else could also be used along with loops just like do-while.
  • A person using WebDriver does not require to know about all these languages, User has to be knowledgeable in only one of them.

The main drawbacks of selenium WebDriver that:

  • It could not support a new browser while it could be done in selenium RC.
  • To generate testing results automatically selenium does not have any built-in command.

Setup your project in selenium 2.0

Selenium WebDriver overcomes all the limitations of its previous selenium RC version, it offers better support for dynamic website pages where the elements can be changed without the reloading of the page itself. Selenium WebDriver uses a browser for automation because it is supported by a variety of browsers. Moreover the project on selenium WebDriver you will set up depends on both your development environment and programming language.

The projects are usually set up in these programming languages:

  1. Java: These projects are easily set up by using Maven, downloads Java blinding and all possible dependencies to create a project for you.
  2. C#: Bindings are divided into parts of a set of dependency DLLs and signed DLLs. You could download the selenium.net zip file by clicking here.
  3. Python: From the command line you have to run pip install selenium it will add selenium to the Python environment.
  4. Ruby: To add selenium to the Ruby environment you have to run gem install selenium WebDriver from the command line.
  5. Perl: the third party is required for the binding of Pearl which provides documentation on getting started.
  6. PHP: Same third party provide the binding of PHP for your selenium WebDriver like by Facebook.
  7. JavaScript: Bindings on npm install are offered by selenium projects which can be installed by running selenium WebDriver npm install.

Selenium WebDriver performs like a normal library once the setup of your project. It does not need to run any kind of installers before its use, neither the need for any additional processes to start. However, some other setup steps are required for

  • Chrome driver
  • Android driver
  • Opera driver
  • IOS driver

Download and install selenium WebDriver:

Installation of selenium is done in 3 steps:

  1. Installation of Java SDK.
  2. Installation of Eclipse.
  3. Installation of selenium driver files.

Step 1-installation of Java on your PC

Click here to download and install the Java software development kit (JDK).

Next-

  • You do not require to separately download and then install JRE because the JDK version comes bundled with JRE.
  • After the process of installation you need to open the command prompt and then type Java. When you will see this screen then it is good to move to our next step.

Step 2-Installation of Eclipse IDE:

You can click here to download the latest version of Eclipse IDE. You have to be sure about the version of the window 32 bit or 64 bit correctly.

You can download the setup.exe file with the name of “eclipse-inst-win64”.

You can install Eclipse by double-clicking on the file. Then you have to click on Eclipse IDE for Java Developers.

Now click button mark 1 to change the path to “C: eclipse” and after that click on install button mark 2.

A new window will come after the installation process with a launch button on it.

Step 3-Downloading of Selenium Java Client Driver.

By clicking here you can download selenium Java Client Driver.

First of all, you have to choose your language we are selecting Java here.

You have to extract ZIP file content on C drive that has downloaded with a file name of “selenium-3.14.0.zip”.

Creation of a new project:

You can create a new project through clicking on File then New and finally on the JAVA project.

After that a new popup window will come with these following details:

  1. The name of a project
  2. Location
  3. The selection of extraction
  4. The layout of a project
  5. Finish button
  • After the new project created Right-Click on it.
  • Then select New>Package.
  • Now give a Name to that Package.
  • By right-clicking on a new package create a new class. Select New>Class, then give a name to it as “MyClass”.
  • After giving the name to the class click on the finish button that will look like this after creation.

Now select properties by right-clicking on the new project.

Now click on “Java build path>libraries tab>Add external JARs.

  • After that select JAR files, you want to add and finally click on the ok button.
  • Select all the files inside and outside of the lib folder.
  • After that click on the “Apply and Close” button below.
  • Finally click on the ok button and you are done with importing Selenium libraries in your project.

WebDriver Script, JAVA code Sample

By using Java “MyClass” that is created now we will make a WebDriver script.

Importing packages

To get started we need to import these two packages:

  1. org.openqa.selenium.*
  2. org.opemqa.selenium.firefox.FirefoxDriver

If there are some more complicated actions required by a test like accessing some other class, taking screenshots of browser or the manipulation of external files, you will need to import some more packages.

Instantiating Variable and Objects

It is how the driver object is instantiated.

Our Java programs will launch default Firefox profiles if a FirefoxDriver class has no parameters. This Firefox profile is quite similar to launch Firefox in a safe mode.

Launch a Browsers Session

A new browser session is launched with this WebDriver’s get() method and direct it to that URL a tester specifies as a parameter.

Have an Actual Page Title

To get the page title of the loaded page we use getTitle() method in the WebDriver.

Comparison of Actual and Expected Values

This part of the code uses Java if-else structure, the comparison between expected title and the actual one.

Terminate browser Session

The browser window is closed with the method of close ().

Run the testing

  • Click run>run on the eclipse’s menu bar.
  • You can also press Ctrl + F11 to run the code.

Ellipse will output “Test Passed!” if everything is done correctly.

Upload and Download a File with Selenium WebDeiver

We simply use the method of sendkeys() to upload files in WebDriver.

In Selenium WebDriver the upload popup file is handle as:

Let’s suppose we want to upload a file “C:\newhtml”. Then the code of WebDriver should be like below.

package newproject;

import org.openqa.selenium.*;

import org.openqa.selenium.firefox.FirefoxDriver;

public class PG9 {

    public static void main(String[] args) {

        System.setProperty(“webdriver.gecko.driver”,”C:\\geckodriver.exe”);

        String baseUrl = “http://demo.guru99.com/test/upload/”;

        WebDriver driver = new FirefoxDriver();

        driver.get(baseUrl);

        WebElement uploadElement = driver.findElement(By.id(“uploadfile_0”));

        // enter the file path onto the file-selection input field

        uploadElement.sendKeys(“C:\\newhtml.html”);

        // check the “I accept the terms of service” check box

        driver.findElement(By.id(“terms”)).click();

        // click the “UploadFile” button

        driver.findElement(By.name(“send”)).click();

        }

}

You will upload the file successfully after running the script and you will get a message like this.

You have to remember these two things while uploading a file in WebDriver.

  1. The stimulating “browser” of the browser button is not required. Your file path will automatically loaded in the file selection box of <input type=”file”> element.
  2. For the Black slash you have to use proper escape characters when you are setting your file path in Java IDE.

What is Wget?

WebDriver is not able to assess download dialogue boxes but we can access them by using a program called Wget.

“Wegt is a command-line program that is small and very easy to use for automatic downloads. We can assess wget from a web driver script to perform downloading.”

Downloading and installation of testNG in eclipse selenium driver WebDriver.

This is a complete step by step guideline that how to install testNG in eclipse:

Step 1-Launch eclipse.

  1. First click on Help on the menu bar
  2. Select “install new software” option

Step 2-

  1. Enter “http://dl.bintray.com/testng-team/testng-eclipse-release/” in work with the place.
  2. After that, strike the add button.

Step 3-Add repository dialogue

  1. In the name field enter “TestNG”.
  2. Click the Add Button.

Step-4

  • Select the checkbox of testNG and then click on the Next button.

Step-5

  • This will give a review of the item going to be installed, click Next.

Step-6

  • Click the button of “I accept the terms“.
  • Finally, click on finish.

Step-7

  • If you will encounter some security warnings you just need to click on Install Anyway.

Step-8

  • Wait for the installation to be completed and then click on restart now.

Step-9

  • After restarting you have to verify testNG successfully installed.
  • Click window>Show>View>Other.

Step-10

  • Now you have to open Java directly to see if testNG has been included.

That is the installation of testNG.

Download and Install Selenium IDE for Firefox

You need the following for this purpose:

  • Mozilla Firefox
  • Internet connection

If you do not have Firefox then you could download it from this link.

  • Then click on add Firefox you have to wait until the completion of download.
  • You will get a notification when the installation will complete then click ok.
  • Now you have to click the icon of Selenium IDE.
  • After that Selenium IDE will open.

Firefox DevTools.

If we want to check the HTML elements of a website application under the testing then Firefox facilitators with its Firefox DevTool future.

  1. You have to right-click on the screen anywhere and select inspect element.
  • After that you will see an interface like this:
  • You can choose XPath by right-clicking on an element that is useful for the identification of an object.

Note: to identify object’s properties, you could also use developer tools in the chrome.

Plugins

Selenium IDE support some additional Firefox plugins created by some other users. You can visit their site to get a list of selenium add-ons available. Install the same way you do with other add-ons in Firefox.

Basically selenium IDE comes with four plugins.

  • Selenium IDE: C formatters
  • Selenium IDE: Java formatters
  • Selenium IDE: python formatters
  • Selenium IDE: Rubi formatters

Selenium IDE is always required for plugins to convert in various formats.

User extensions

To provide advanced capabilities selenium I could also support user extensions. These are in the form of Javascript files. By specifying their exact path you can install them in these two fields.

  1. Selenium core extensions.
  2. Selenium IDE extensions.

You will find a load of user extensions by clicking here.

Conclusion

This was the basic overview of installing various components of Selenium and introduction to its basic operations, if you have any questions or suggestions, let us know about it in the comments below.

If you’re an individual or team looking for Selenium Testing Services or any other Software Testing Services, you can head over to our Services Page and avail our promotional 20 hours of Free Testing.

Leave a Reply

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