Upgrading to Selenium 3

February 7, 2017


If you have your tests created using WebDriver 2.x and want to upgrade it to Selenium 3, following are few simple steps to get started with Selenium 3:

  1. Download geckodriver, it is released by Mozilla which would run along the browser
  2. Set the path of the geckodriver using System Property as:
    • Example:
      System.setProperty("webdriver.gecko.driver","/home/wherever/geckodriver");
    • Note: You can place the geckodriver anywhere on the system even inside your project
  3. Update Selenium version in dependency to 3.x in your POM.XML file:
    • Example:
      <dependency>
       <groupId>org.seleniumhq.selenium</groupId>
       <artifactId>selenium-java</artifactId>
       <version>3.0.1</version>
       </dependency>
  4. Update your Java version to 1.8 in the build path as it won’t work with earlier versions of JAVA

A simple scenario which is often used in JMeter while Load Testing when we want to pass the value of a dynamically generated value of a parameter from one page to another.

  • Create a new project in JMeter
  • Add a Thread Group
  • Add an HTTP Sampler
  • Configure the HTTP Sample by providing Server Name/IP, Port and Path of the website to run the Test on, I’ll use Google here in our example

    First Request

    First Request

  • Add ‘View Results Tree’ listener to the Thread Group
  • Execute the project to make sure if the request was configured properly
  • Now suppose I want to get the value from the response of the first request, store it in a variable and use it in another request. To do that, add a “Regular Expression Extractor” element in the HTTP Sampler (available in Post Processors)
  • In the Regular Expression Extractor, type a Reference Name (Variable Name) such as ‘extractionDemo’
  • Type the regular expression in the regular expression field, in my example I want to extract the value of what was searched such as ‘Hello World’, for that I’ll use the following expression:

<input id=gbqfq name=q type=text autocomplete=off value=”(.+?)” >
(To test the expression, Click ‘View Results Tree’, select Regex Tester from the drop down menu and insert you regular expression in the Regular Expression field, click Test)

  • The above regular expression would extract the string available in value attribute and store it in a variable named “extractionDemo’
  • Type $1$ in Template field
  • Type 0 in Match No. field (0 for Random, 1 for first match and so on)

    Regular Expression Extractor

    Regular Expression Extractor

  • Add another HTTP Sampler and configure it’s Server Name, Port and Path
  • Add a Parameter to the request and in the value type ${extractionDemo}

    Second Request

    Second Request

  • Now execute the test and wait for it to complete. After the tests have finished executing, click ‘View Results Tree’, you would see two requests click the second request and click Request tab you would see that the value that was extracted from the first Response is not being used as value of Parameter of the Second Request.

    View Results Tree

    View Results Tree

Happy Testing!!!


Before configuring Badboy script to Jenkins CIS, make sure you have:

Prerequisites:

  • Installed ANT on your system
  • Created and saved Badboy (*.bb) script
  • Downloaded the Badboy Ant Plugin Jar file
  • Setup Environment Variables for ANT and Badboy

Download the following Jar file containing the plugin tasks and copy them in your ANT “lib” directory
http://badboysoftware.biz/ant/badboytasks.jar

Environment Variables to Set:

  • ANT_HOME: Path of the AN T installation directory
  • Add the ANT “bin” directory to the Path environment variable by inserting %ANT_HOME%\bin
  • Add the Badboy installation directory to the Path environment variable such as “C:\Program Files\Badboy”
  • Test the path environment variables by opening the cmd.exe and type the following commands:
    • For ANT: type ant, its working if it displays “Build.xml doesn’t exists”.
    • For Badboy: type badboy, if the badboy IDE is displayed it working.

Create a build.xml file and copy the following code:

<?xml version=”1.0″ encoding=”UTF-8″?>
basedir=”.” default=”executethis”>
<path id=”classpath”>
<pathelement location=”badboytasks.jar” />
<fileset dir=”PATH TO YOUR ANT LIB DIRECTORY“>
<include name=”**/*.jar” />
</fileset>
</path>
<taskdef name=”runscript” classname=”com.badboy.ant.RunScriptTask” classpathref=”classpath”>
<target name=”executethis”>
<runscript script=”NAME OF YOUR TEST SCRIPT.bb”>
<!–runscript>
</target>
</project>

Note: Please insert the location of the ANT>LIB Directory in fileset tag such as “D:\Tools\Testing\ant\lib” and name of your Test Script in runscript tag.

Now copy the Badboy Script (*.bb) and build.xml file in a folder and type the following command using cmd.exe: (Make sure both files are in the same directory and you have navigated to that folder in CMD)

  • ant –f build.xml

This will start Badboy and cause it to run the script from beginning to end without stopping. if the script has errors or assertion failures it will cause the build to fail and abort . If you prefer different behavior you can stop the build from failing when a script fails by simply adding a failOnError attribute and setting it to false:

failOnError=”false”/>

If you want to pass variables to your script then you can easily add them as child elements:

<runscript script=”Script.bb”>
<var name=”var1″>URL</var>
<var name=”var2″>TimeOut</var>
</runscript>

Parameters

Attribute Description Required
script The name of the script to run. Yes
report The name of the file to save the HTML report output to. No; Defaults to “badboy.ant.html”.
failOnError true or false – controls whether errors or assertion failures in the script are treated as a build failure. No; Defaults to true.
resultsproperty The name of the property under which script summary results are stored. No; defaults to “badboy.script”.

Once this is successful, we are ready to configure it over Jenkins CIS.

Creating Badboy Test Execution Job Over Jenkins CIS:

  • Go to your Jenkins homepage and click New Job
  • Type the name of the Job and Select “Freestyle Project”
  • Click Next
  • Type in Description of the Job if you want to.
  • In the Build section, click Add Build Step > Invoke ANT
  • Click Save at the bottom of the page.
  • Click Build Now, the build would Fail as we haven’t copied our files in to Jenkins job workspace.
  • Click the Build#1 in the Build History Panel
  • Now click Console Output
  • Console output would display the logs, copy the “Buildfile:” path such as:

Buildfile: C:\Users\Zuhaib.ahmed\.jenkins\jobs\Badboy\workspace\build.xml

  • And open that path in Windows Explorer
  • Copy build.xml and Badboy Script file in the Jenkins job workspace directory.
  • Click Build Now and this time the Job would run successfully.

If you want to notify all the build stackholders through email, you can enter the recipient list. If you want enhanced/advanced email reporting install “email-ext” plugin for Jenkins and use the Jelly Content.

Since Badboy generates HTML reports after test execution, we’ll need to install “HTML Publisher Plugin” for Jenkins in order to display them on Jenkins. Following is an example of how the HTML results would be displayed:

Image

Happy Testing!!!


If you are looking for options in Server side resource monitoring, here is one:

http://mubbashir11.blogspot.com/2011/10/server-side-monitoring-in-jmeter-with.html


We recently came across a problem when we were getting frequent exceptions by a Java EE application connected and dependent on other utilities and applications due to excessive memory and CPU usage when loads of requests were sent to the application, we started load testing the application and used JavaMelody for monitoring the server resources.

JavaMelody is opensource (LGPL) and production ready tool to monitor Java or Java EE application servers in QA and production environments. It is not a tool to simulate requests from users, it is a tool to measure and calculate statistics on real operation of an application depending on the usage of the application by users.

It includes summary charts showing the evolution over time of the following indicators:

  • Number of executions, mean execution times and percentage of errors of http requests, sql requests, jsp pages or methods of business façades (if EJB3, Spring or Guice)
  • Java memory
  • Java CPU
  • Number of user sessions
  • Number of jdbc connections

For further information on JavaMelody please visit the following URL:
http://code.google.com/p/javamelody/

Setup JavaMelody:
Configuring JavaMelody is quite simple and easy:

  1. Download the javamelody.jar and jrobin-x.jar files in a zip file javamelody-x.zip from the following location:
    Download JavaMelody
  2. Extract the zip file and copy the Jar files in WEB-INF/lib directory of the war of the webapp to monitor.
  3. Add the following lines in the fileWEB-INF/web.xml of the war of the webapp, before the description of your Servlet:
        <filter>
                <filter-name>monitoring</filter-name>
                <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
        </filter>
        <filter-mapping>
                <filter-name>monitoring</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>
        <listener>
                <listener-class>net.bull.javamelody.SessionListener</listener-class>
        </listener>

Following is the snapshot of the web.xml:

web.xml file

Snapshot of the web.xml file

Note: If your application server is compatible with Servlet API 3.0 (like tomcat 7, glassfish v3 or jboss 6), Step 3 is generally not needed, you can skip it and launch the server as in the next paragraph, except if you use a web.xml file without version=”3.0″. If you add these lines in a Servlet API 3.0 webapp, you may also add <async-supported>true</async-supported> in the filter to support asynchronous requests.

You Application is now ready for monitoring, start the server and open the following page in the browser:
http://<host>/<context>/monitoring

Host: Name of the server where application is deployed
Context: Name of the context of the webapp

When you’ll open the monitoring page, you would see different graphs indicating CPU and Memory usage etc, here is the snapshot:

Monitoring Results

Monitoring Results

Monitoring Results

Monitoring Results

JavaMelody is configurable according to your needs for:

  • Generating Reports
  • URL Pattern to monitor/not to monitor URLs
  • JDBC for SQL request monitoring
  • Business Facades
  • Weekly, Monthly or Daily reports by email
  • JavaMelody Plugin for Hudson

For details please visit JavaMelody Documentation available on http://code.google.com/p/javamelody/.

Happy Testing !


Lets begin with introduction of the tool I am going to use for testing web services, that is SoapUI:

“SoapUI is a free and open source cross-platform Functional Testing solution. With an easy-to-use graphical interface, and enterprise-class features, SoapUI allows you to easily and rapidly create and execute automated functional, regression, compliance, and load tests. In a single test environment, SoapUI provides complete test coverage and supports all the standard protocols and technologies.”

I will not explain all the features of SoapUI so please go through the detailed documentation of SoapUI available on eviware website:

http://www.eviware.com/soapUI/what-is-soapui.html

Download SoapUI from the following site (the latest versions are backward compatible):

Download SoapUI

I am going to use a publicly available WSDL (Bing) for the tutorials so that we all are on the same page, please note the WSDL URL:

http://api.bing.net/search.wsdl

You can also get help from the following documentation (Bing API Basics):

http://www.bing.com/developers/s/API%20Basics.pdf

Also you need to create an AppId to use Bing API because it is a required field in the WSDL, you can do so by signing up here:

http://www.bing.com/developers/createapp.aspx

Lets Start with creating a new project in SoapUI:

  1. Click File > New SoapUI Project
  2. Type a project name
  3. Insert the WSDL EndPoint in the WSDL Text Box (http://api.bing.net/search.wsdl)
  4. Leave all the check boxes unchecked except for “Create sample requests for all operations”.
  5. Click OK.

Now we are ready to use and test the web services. Since the Bing API has also one operation in the WSDL (Search()) expand it, you will see a Request option under it, double clicking the “Request” will open the editor window:

You would see plenty of elements available in the request for different purposes such as Web Search, Image Search etc, because exploring the Bing API is beyond our scope we will not discover them all. We’ll create a simple web search using minimal required fields in the Request. Copy/Paste the following request in your request editor (Provide your AppId which you created using the steps provided above) and execute it with the help of the Play/Execute button available in the upper left corner of the editor:

Request:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:sear=”http://schemas.microsoft.com/LiveSearch/2008/03/Search”&gt;
<soapenv:Header/>
<soapenv:Body>
<sear:SearchRequest>
<sear:parameters>
<sear:Query>bing</sear:Query>
<sear:AppId>D5D9ACDF440248EA41EC324C3B867AFDE63319CB</sear:AppId>
<sear:Sources>
<!–Zero or more repetitions:–>
<sear:SourceType>web</sear:SourceType>
</sear:Sources>
<!–Optional:–>
<sear:Web>
<!–Optional:–>
<sear:Offset>0</sear:Offset>
<!–Optional:–>
<sear:Count>1</sear:Count>
</sear:Web>
</sear:parameters>
</sear:SearchRequest>
<!–soapenv:Body>–>
<!–soapenv:Envelope>–>

Executing it would give you the following response:

Response:

<!–pageview_candidate–>
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”&gt;
<soapenv:Body>
<SearchResponse xmlns=”http://schemas.microsoft.com/LiveSearch/2008/03/Search”&gt;
<parameters>
<Version>2.2</Version>
<Query>
<SearchTerms>bing</SearchTerms>
</Query>
<Web>
<Total>911000</Total>
<Offset>0</Offset>
<Results>
<WebResult>
<Title>Bing</Title>
<Description>Bing is a search engine that finds and organizes the answers you need so you can make faster, more informed decisions.</Description>
<Url>http://www.bing.com/</Url&gt;
<CacheUrl>http://cc.bingj.com/cache.aspx?q=bing&amp;d=4523786176561420&amp;w=7c43e585,779e3b42</CacheUrl&gt;
<DisplayUrl>www.bing.com</DisplayUrl>
2011-04-24T16:32:00Z
<DeepLinks>
<DeepLink>
<Title>Search History</Title>
<Url>http://www.bing.com/profile/history?FORM=Z9LH12</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing Search History</Title>
<Url>http://www.bing.com/profile/history</Url&gt;
</DeepLink>
<DeepLink>
<Title>United States</Title>
<Url>http://www.bing.com/worldwide.aspx?FORM=WHLH</Url&gt;
</DeepLink>
<DeepLink>
<Title>Local – Bing News</Title>
<Url>http://www.bing.com/news/search?q=&amp;p1=%5bNewsVertical+Category%3d%22rt_Local%22%5d</Url&gt;
</DeepLink>
<DeepLink>
<Title>Maps</Title>
<Url>http://www.bing.com/maps/</Url&gt;
</DeepLink>
<DeepLink>
<Title>Entertainment</Title>
<Url>http://www.bing.com/entertainment?FORM=Z9LH11</Url&gt;
</DeepLink>
<DeepLink>
<Title>Business – Bing News</Title>
<Url>http://www.bing.com/news/search?q=&amp;p1=%5bNewsVertical+Category%3d%22rt_Business%22+View%3d%220%22%5d</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing Community</Title>
<Url>http://www.bing.com/community/blogs/search/archive/2009/08/17/welcome-home.aspx?&amp;form=pgbar1</Url&gt;
</DeepLink>
<DeepLink>
<Title>Sports – Bing Videos</Title>
<Url>http://www.bing.com/videos/browse/sports?q=browse:sports</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing Maps For India</Title>
<Url>http://www.bing.com/mapindia/?FORM=Z9LH3</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing تفضيلات</Title>
<Url>http://www.bing.com/settings.aspx?sh=5&amp;ru=%2f&amp;FORM=FLLH</Url&gt;
</DeepLink>
<DeepLink>
<Title>Travel</Title>
<Url>http://www.bing.com/travel/</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing Preferences</Title>
<Url>http://www.bing.com/settings.aspx?sh=5&amp;ru=%2f&amp;FORM=FTLH</Url&gt;
</DeepLink>
</DeepLinks>
</WebResult>
</Results>
</Web>
</parameters>
</SearchResponse>
<!–soapenv:Body>–>
<!–soapenv:Envelope>–>

Success… :) Response seem to be valid, lets check manually if it is really valid …

I requested a simple web search using Bing for the keyword “Bing”, and restricted the count to 1 which means show me only 1 result. Notice that some of the elements have values such as under the <WebResult> element we have several other elements such as Title, Description, URL etc each having their own values.

Note: This was the most Basic tutorial of Creating a new Web-Services project in SoapUI, Executing the Request and Receiving the Response. I intend to share this series from Basic to Advanced so that beginners can learn as well.

See you in the next part, where we’ll see how to put some useful assertions to confirm the response.

Happy Testing !!!


Hi,

I started testing web services in 2008 from the scratch and learned many things since then along with web application testing so I think now is the time when I should transfer my knowledge via my blog so that it may help my fellow testers who are new or are struggling in testing web services. I’ll be demonstrating the beginner level tutorials in this series for both SOAP/REST respectively.

I’ll be using an open source tool “SoapUI” by SmartBear because its easy to use/understand, availability of detailed level documentation and last least but not least its free.

Following are the parts we are going to cover in this series:

  • Creating a simple Web Services project in SoapUI and executing the request and analyzing the response.
  • Advanced techniques of testing Web Services using SoapUI i.e. Loading the variable and assertion values from Test.Properties file etc.
  • Automating the web services project using SoapUI.
  • Configuring the job of automated SoapUI project over Hudson CIS (Continuous Integration Server) for monitoring.

Please hold on, soon I’ll be publishing the Introduction part.

Happy Testing !!!


Summary of the Error I am gonna troubleshoot here:

java.lang.OutOfMemoryError: GC overhead limit exceeded

A couple of weeks ago I was assigned the task of migrating Hudson to a new machine with the latest version of Hudson. Installed Hudson (version 1.361) deployed over Tomcat 6, configured several Jobs including:

  • Checkout, Compile and Run JUnit Test Cases on the Build and record them using PMD, FindBugs and Cobertura Code Coverage Test Reports.
  • Configured WS (Web Services) Tests using SoapUI.

The first job of compilation and executing JUnit tests was running fine but when running a bigger job I was getting the following error:

“java.lang.OutOfMemoryError: GC overhead limit exceeded“

I tried running the tests multiple times just to make sure if it might work fine but no luck. Searched the web, people suggested try increasing the memory in the JAVA_OPTS option, I did that but got the same error, similarly tried increasing the Xmx memory of Ant, SoapUI.sh, Catalina.sh, Java… but it didn’t cure.

Later after a lot of efforts of debugging the issue, I found out the cause that build file of CIS is run by testrunner.sh which was lacking memory and throwing the exception on executing larger test suites, I just increased the -Xmx memory in testrunner.sh file of SoapUI in the bin folder and executed the job successfully.

It was so easy to do, but sometimes we miss basic things as we never think in those directions.

But anyways it was Happy Testing in the end 🙂

Design a site like this with WordPress.com
Get started