Showing posts with label ChromeDriver. Show all posts
Showing posts with label ChromeDriver. Show all posts

Friday, November 20, 2015

Protractor : How to install protractor environment?

Protractor is a end to end test framework for automating AngularJS application that has special angular element locating feature and it can automatically control the waiting time between two steps which selenium needs to handle using different implicit and explicit wait technique.
In our previous post we have discussed about Protractor and its features. Now how we can install protractor in our windows machine will be discussed here.

Prerequisites :
Node.js : Protractor is a Node.js program. So we need to install Node.js before installing protractor.
Jasmine : Protractor uses Jasmine Framework by default. It is not needed to install Jasmine separately.
Java Development Kit (JDK) : For running selenium Standalone server it is needed to install JDK.

Step 1 : Install JDK
How to install JDK is found in my another post. Also you can visit to Java download page to download and install JDK. You can also take help from this link to install JDK

Step 2 : Install Node.js application
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It is lightweight and efficient.
image
  • Double click on the installer file. In my case it is “node-v5.0.0-x86.msi”. A pop up window is displayed.
  • Click on Run button.
image
  • Node.js setup window is displayed. Click on Next button.
image
  • Check on the checkbox named “I accept the terms in the License agreement”. Click on Next button.
image
  • Keep the destination path same in this window and click on Next button.
image
  • Click on Next button.
image
  • Click on Install button.
image
  • A pop up window is displayed and click on Yes button.
image
  • Installation starts.
image
  • Click on Finish button.
image
  • Node.js installation is now complete.
  • In order to verify that node.js is installed properly, open command prompt window by writing “cmd” text in the run text box and press Enter key from Keyboard.
image
  • Command prompt window is displayed and type the following command.

node –version

 image

  • Inspect that node.js version 5.0.0 is displayed.
image
  • It is proved that node.js is installed properly.
Step 3 : Install Protractor
  • Open Command prompt typing the text “cmd” at run text box and press enter button.
image
  • Command prompt window is displayed.
image
  • Type the following command to install protractor globally. Note that it installs two command line tools – protractor and webdriver-manager. It also installs Protractor API (library).
npm install -g protractor
image

Note that we use “–g” in the command line to install protractor globally.



  • Press Enter key.
  • Protractor starts installing.

image


  • After finishing installation type the following command to verify that protractor has been installed successfully.

protractor --version

image


  • Press Enter key.
  • It shows the protractor version. It means that protractor has been installed successfully.

image


  • Now type the following update command that will install standalone selenium server and ChromeDriver.

webdriver-manager update

image


  • Press  enter key and it starts installing.
  • After finishing installation run the standalone selenium server to verify that it is running. We need to run it before executing protractor test script. The command will be,

webdriver-manager start

image
Now our environment is ready to run protractor test script. So it’s time for writing protractor test. Our next post will be on that topic.

Happy UI Testing with Protractor!!!

Monday, June 29, 2015

Selenium : How to add Selenium Webdriver package to a Visual Studio project

If we automate our application using C# API of Selenium Webdriver then we need to create a Visual Studio project and add Webdriver reference to that project. In that case we need to download Selenium API for C# from download page of Selenium official site and then add reference to that project or install Selenium Webdriver package from Nuget.org using Nuget package manager. Here we will show on how we add Webdriver reference from Nuget. 

Step 1 : Go to Solution Explorer and Right click on Reference and click on Manage NuGet Packages…

Step 2 : Manage NuGet Packages window is displayed.

Step 3 : Enter the text Selenium WebDriver at search text box and press enter from Keyboard

Step 4 : Selenium WebDriver package is displayed at Search list.

Step 5 : Click on Install button.

Step 6 : Latest WebDriver will be installed and added as Reference.

 

Step 7 : Select Selenium WebDriver Support Classes package and click on Install button.

Step 8 : After finishing installation and click on Close button to close the Package Manager window.

Step 9 : Now verify that all the References are showing properly at the solution explorer.

image

Wednesday, September 17, 2014

How to run Selenium IDE script in different browser

We can easily create selenium script through Selenium IDE and run those scripts on Firefox browser.If you have no idea about selenium script, please visit my other post on IDE (How to record and run scripts with Selenium IDE).
But in order to do cross browser testing we need to run the script on other browsers like chrome, Internet Explorer etc.
Selenium IDE has given a feature (that is still experimental stage) where we can run our recorded IDE scripts through Chrome, Internet Explorer etc.
Step 1 : Download Selenium Standalone server and Browser driver server
Download the selenium Standalone server from the location (http://www.seleniumhq.org/download/).
image
Download the Browser Driver from the following location.
  • Internet Explorer(IE) driver :
    • Go to the location (http://www.seleniumhq.org/download/).
    • Note that there are two different version for 32 bit and 64 bit windows. Click on the appropriate link (32 bit windows IE or 64 bit windows IE) according to your windows OS version (32 or 64 bit).
image
image
image
  • Click to download the latest chrome driver. Here I have downloaded version 2.10. But it might be more latest version in future release. Clicking on this link will go to the following page.
image
  • Click on the above selected link and download the zip file. Unzip the file and copy the EXE file to a single location where Selenium Standalone server and IE driver are located.
Step 2 : Configure Selenium IDE
  • Open Selenium IDE
  • Go to Options
  • Click on Options menu
image
  • Selenium IDE options window is displayed and click on Webdriver tab.
image
  • Now check Enable Webdriver Playback options
  • Enter the full name of the browser you want to run your script in the text box below the checkbox. For example, in case of IE, we need to type “internet explorer”. In case of other browser, we can enter chrome, android, firefox, htmlunit, iPhone, iPad, opera.
image
  • Click ok button
  • Now restart the Selenium IDE. A restart is required to enable and disable webdriver. By default this option is disabled at selenium IDE.
Step 3 : Run Selenium Standalone server and Browser driver server
  • Before running this server ensure that java runtime environment is already installed on that machine as this is required to run JAR file. If not then download it from specific location.
  • Open the command prompt by using admin privilege (Run as administrator).
image
  • Go to the location where the Selenium Standalone server JAR file located. In my case, this is C:\Run location.
image
  • If you want to run your script on Internet explorer then type following command where both Selenium Standalone server and IE driver will start running.
java -jar selenium-server-standalone-2.42.2.jar -Dwebdriver.ie.driver=IEDriverServer.exe
image

image
  • In case of chrome driver the command will be
java -jar selenium-server-standalone-2.42.2.jar -Dwebdriver.chrome.driver=chromedriver.exe
All of the cases the command syntax will be
java -jar seleniumStandaloneServerFileName.jar -Dwebdriver.BrowserName.driver=.BrowserDriverServerFileName.exe

Note that every time we run the selenium standalone server with the browser driver server.

Step 4 : Run Selenium IDE scripts
  • Open Selenium IDE.
  • Load the recorded script file.
  • Run the script.
  • Note that the browser will be pop up and start executing the script.
Selenium IDE script recorded through Firefox browser will now run through other browsers like Chrome, IE etc.

Please comment me on any error you found to execute these steps.
Happy Cross Browser Testing!!!

Wednesday, August 13, 2014

Running Selenium Webdriver script in different browsers

In cross browser testing, we need to run selenium webdriver script on different browser like Firefox, Chrome and Internet Explorer etc. In order to do that we need to declare the webdriver for different browsers.

Firefox:
There is a Firefox driver class at Selenium webdriver package.
import org.openqa.selenium.firefox.FirefoxDriver;
The driver declaration will be :
In Java,
Webdriver driver=new FirefoxDriver();
Internet Explorer:
In case  of internet Explorer, the implementation is different. You have to download the internet explorer driver server from http://docs.seleniumhq.org/download/ page at the section “The Internet Explorer Driver Server”. There are two version present for windows 32 bit and 64 bit version. Download your appropriate version and Unzip the folder and rename it and place it in a suitable place of your project. There is a single executable file on the folder in named “IEDriverServer.exe”.
We need to add a package for this IE.
(In Java)
import org.openqa.selenium.ie.InternetExplorerDriver;

In driver declaration section, at first we have to define the path where this file is located using setProperty() function that takes the browser specific driver name and downloaded driver file path as the argument.

System.setProperty(DriverName, FilePath);

Here DriverName is in format like "webdriver.ie.driver". FilePath is like “C:\\Development\\…….\\IE Driver\\IEDriverServer.exe"

So the implementation will be (In Java),
System.setProperty("webdriver.ie.driver", "C:\\Development\\IE Driver\\IEDriverServer.exe");

The driver declaration will be (In Java),
Webdriver driver=new InternetExplorerDriver();

Chrome:
In case  of Chrome, the implementation is different but almost same IE driver described before. You have to download the Chrome driver server from https://code.google.com/p/selenium/wiki/ChromeDriver page. Click on “Download Driver” link will go to download page where there are different versions of drivers are displayed. Download the latest version. Unzip the folder and rename it and place it in a suitable place of your project. There is a single executable file on the folder in named “chromedriver.exe”.
We need to add a package for Chrome.
(In Java)
import org.openqa.selenium.chrome.ChromeDriver;
In driver declaration section, at first we have to define the path where this file is located using setProperty() function that takes the browser specific driver name and downloaded driver file path as the argument. So the implementation will be
(In Java),
System.setProperty("webdriver.chrome.driver", "C:\\Development\\chromedriver_win32\\chromedriver.exe");
The driver declaration will be (In Java),
 Webdriver driver = new ChromeDriver();
After driver declaration, your webdriver script will be same for all the three browsers.

In future post, I will describe on other browsers like opera and safari. Thanks !!


Cypress: How to handle browser-based authentication pop up dialog in Cypress

Five years ago I have written a blog on how to handle browser-based authentication for selenium webdriver.   Now it is for cypress. Cypress...