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, June 17, 2015

JMeter : How to configure your browser proxy connection for recording HTTP request

In order to record HTTP request using JMeter recording controller we need to configure browser proxy connections. We can use any of the browser for recording. Here we will discuss on how we can configure Firefox, Internet Explorer and Chrome browser.

At first we have to open the browser window where the web application will run and change its Proxy server settings.

Firefox Browsers:

  • Open Firefox Browser
  • Go to Tools->Options

image

  • Options page is displayed, Note that I am using Firefox version 38.0.5
  • Click on Advanced Tab
  • Click on Network sub tab
  • Click Settings button of the Connection area.

image

  • Connection Settings window is displayed
  • Select Manual Proxy configuration
  • Enter HTTP Proxy as “localhost”
  • Keep port as “8080”
  • Make sure that “Use this proxy server for all protocols” option is checked
  • Click OK button of Connection Settings window

image

  • Close the Browser window

Internet Explorers:

  • Open Internet Explorer
  • Go to Tools>Internet Options

image

  • Internet options window is displayed
  • Click on Connections tab
  • Click on LAN Settings button

image

  • LAN Settings window is displayed
  • Uncheck “Automatically detect settings”
  • Check the “Use the proxy server for your LAN” options
  • Type address as “localhost” and port as “8080”
  • Click OK button of the LAN Settings window

image

  • Click OK button of Internet Options window

image

  • Close the Browser window

Chrome Browser:

  • Open Chrome Browser
  • Click on Customize and control Google chrome button located at top right corner. A drop down menu is displayed.

image

  • Click on Settings option

image

  • Settings page is displayed.
  • Scroll down to the bottom of the page and click on Show Advanced Settings link to expand the page.

image

  • Click on Change Proxy Settings…

image

  • Internet Properties window is displayed and click on Connections tab.
  • Click on LAN Settings button.

image

    • LAN Settings window is displayed
    • Uncheck “Automatically detect settings”
    • Check the “Use the proxy server for your LAN” options
    • Type address as “localhost” and port as “8080”
    • Click OK button of the LAN Settings window

    image

    • Click OK button of Internet Options window
    • Close the browser window.

    Happy Load testing with JMeter!!!…..

    Sunday, June 14, 2015

    Selenium : How to handle browser based authentication using Selenium Webdriver

    Couple of years ago, I got an issue about browser based authentication and I googled about it and found the resolution. In recent days I face the same problem. I forgot to fix and again googled and found lots of automated testers like me are facing the same problem. Now I decide to write a small post on it so that I can remember every time from my post and also I can help our automated testers.

    A very simple syntax to handle the browser based authentication,

    If we have username and password and the URL then requested URL will be,

    http://username:password@domainName.com

    Note that we have a special character colon “:” between username and password.

    For example, we have
    username : abc
    password : abc123
    URL : xyz.com
    then the requested URL for Selenium Webdriver command,
    abc:abc123@xyz.com
    So the Selenium Webdriver command to open application in a browser,

    (C#)
    driver.Navigate().GoToUrl("http://abc:abc123@xyz.com/");

    (Java)
    driver.get("http://abc:abc123@xyz.com/");

    Thank you…..
    Enjoy automated testing using Selenium Webdriver….!!!

    Wednesday, June 10, 2015

    JMeter : How to record HTTP request and perform load test using JMeter

    JMeter is a web load and performance testing tool that has been used for a long time. As an open source tool it is popular to many web load and performance tester. I am using it for a long time. In my previous post on JMeter I have shown how to download and install JMeter. 

    In this blog, I will show you how to record http request and perform a Load test using JMeter. Our test case steps for load testing is given below:

    1. Open the Browser and go to the site : http://www.bing.com/
    2. Enter the text “JMeter” at search text box
    3. Click Search button and JMeter related page with link is displayed
    4. Click on the link text “Apache JMeter - Apache JMeter™”

    Step 1 : Start JMeter Application

    Start JMeter windows application by double clicking on the file named ApacheJMeter.jar at the bin directory (In my case, C:\apache-jmeter-2.13\bin)

    Tips : Make a desktop shortcut for ApacheJMeter.jar file so that every time you do not need to visit bin folder.

    Note that I am using the latest JMeter version 2.13

    JMeter window is displayed. Inspect that it has two panels. Left panels shows the options part or planning part where tester can add different options for testing purpose. Right panel displays the details window where tester can configure different option.

    image

    Step 2 : Creating Test Plan

    • Click on Test Plan from Left panel
    • Note that clicking on Test Plan from Left panel will display plan details on right panel.

    image

    • Remove the default text “Test Plan”
    • Enter the text “Bing Search” in the Test Plan Name text box
    • Click on Workbench option in the left side and inspect that Default Test plan name changes to “Bing Search”

    image

    Step 3 : Adding Thread Group

    In order to simulate the user there is an option Thread Group in JMeter. In our load testing we simulate 5 users in every second.

    • Right click on the test plan “Bing Search” at left panel.
    • Click on Add>Threads(Users)>Thread Group

    image

    • Thread Group option is added at left panel under Bing Search 

    image

    • Rename the thread group name “Load Settings
    • Keep the Option “Continue” as Sampler Error
    • Change the thread properties option Enter 5 at “Number of Threads(Users)“ field
    • Enter 1 at Ramp-Up Period (in seconds)
    • Keep Loop count field “1
    • The thread group window looks like the following figure:

    image

    Step 4 : Adding a recording controller

    • Right click on the Load Settings Thread and click Add>Logic Controller>Recording Controller

    image

    • A new recording controller is added and rename the controller as “Search by Keyword”.

    image

    Step 5 : Adding HTTP(s) Test Script Recorder

    After configuring thread group we need to record the http request. In JMeter, there is a tree node in left panel called workbench. We have to add a HTTP(s) script recorder (proxy server) that will record the HTTP(s) request sent from browser.

    • Right click on WorkBench
    • Click on Add>Non-Test Elements>HTTP(s) Test Script Recorder

    image

    • HTTP(s) Test script recorder is added.
    • Keep the recorder name unchanged.
    • Keep the port 8080.
    • Select Target controller as Search by Keyword. As a result when recording starts it adds HTTP requests to Search by Keyword controller section.

    image

    Note that if you add multiple controller you can change controller from Target controller before recording and record on that section.

    Finally the HTTP Test script recorder looks like the following.

    image

    Step 6 : Configure Browser settings

    • Now open the Browser window where the web application will run and change its Proxy server settings. We have to configure any of the browser that we use for recording.
    • For Firefox Browsers
      • Open Firefox Browser
      • Go to Tools->Options

    image

      • Options page is displayed, Note that I am using Firefox version 38.0.5
      • Click on Advanced Tab
      • Click on Network sub tab
      • Click Settings button of the Connection area.

    image

      • Connection Settings window is displayed
      • Select Manual Proxy configuration
      • Enter HTTP Proxy as “localhost”
      • Keep port as “8080”
      • Make sure that “Use this proxy server for all protocols” option is checked
      • Click OK button of Connection Settings window

    image

      • Close the Browser window
    • For Internet Explorers
      • Open Internet Explorer
      • Go to Tools>Internet Options

    image

      • Internet options window is displayed
      • Click on Connections tab
      • Click on LAN Settings button

    image

      • LAN Settings window is displayed
      • Uncheck automatically detect settings
      • Check the “Use the proxy server for your LAN” options
      • Type address as “localhost” and port as “8080”
      • Click OK button of the LAN Settings window

    image

      • Click OK button of Internet Options window

    image

    • Close the Browser window
    • For Chrome Browser
      • Open Chrome Browser
      • Click on Customize and control google chrome button located at top right corner. A drop down menu is displayed.

    image

      • Click on Settings option

    image

    • Settings page is displayed.
    • Scroll down to the bottom of the page and click on Show Advanced Settings link to expand the page.

    image

      • Click on Change Proxy Settings…

    image

      • Internet Properties window is displayed and click on Connections tab.
      • Click on LAN Settings button.

    image

      • LAN Settings window is displayed
      • Uncheck automatically detect settings
      • Check the “Use the proxy server for your LAN” options
      • Type address as “localhost” and port as “8080”
      • Click OK button of the LAN Settings window

    image

      • Click OK button of Internet Options window
      • Close the browser window.

    Step 7 : Recording HTTP(s) request

    • Go to Workbench.
    • Click on HTTP(s) Test Recorder.
    • Click Start button of the recorder window.

    image

    • Following window might be displayed and click on OK button.

    image

    • Recorder is starting. Note that start button is disabled at that time.
    • Open the browser that has been configured for recording. In my case it is chrome browser.
    • Execute the test case.
    • Go to the site : http://www.bing.com/
    • Enter the text “JMeter” at search text box
    • Click Search button and JMeter related page with link is displayed

    image

    • Click on the link text “Apache JMeter - Apache JMeter™”.

    image

    • JMeter page is displayed.
    • Close the browser window.
    • Click Stop button of the HTTP(s) Test Script Recorder.

    image 

    • Now double click on Search by Keyword controller to see the request.

    image

    Step 8 : Adding Listener to view the result

    • Right click on the Thread group Load Settings
    • Click on  Add>Listener>Summary Report

    image

    • Summary report is added.

    image

    • Add another Listener named View result in Table by the same way.

    image

    • Add another Listener named Graph Result by the same way.

    Note that we will discuss more on Recording controller and Listener in our future post.

    Step 9 : Saving JMeter Test

    • Click on Save button from Toolbar to save the test.

    image

    • Select a location and enter the Test Name Bing Search.jmx

    image

    • Click on Save button

    Note that JMeter ask for saving before executing the test.

    Step 10 : Executing Load Test

    • Go to Thread Group Load Settings
    • Click on the Start button from tool bar.

    image

    • JMeter starts executing the Load.
    • At the time of Load testing Start button is disabled and red color Stop button is enabled.

    Step 11 : Inspect Load Test Result

    After completing the load test inspect the result from Listener.

    • Summary Report

    image

    • View Results in table

    image

    • Graph Result

    image

    Note that each report has so many options. We can save the report data and submit for analysis.

    We will discuss more on JMeter reports on our future posts.

    Thant’s all for now…

    Thank you for following it….

    Happy Load testing with JMeter!!!…..

    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...