Monday, May 19, 2014

Css Selector Vs Xpath



10 down vote accepted
CSS selectors perform far better than Xpath and it is well documented in Selenium community. Here are some reasons,
  • Xpath engines are different in each browser, hence make them inconsistent
  • IE does not have a native xpath engine, therefore selenium injects its own xpath engine for compatibility of its API. Hence we lose the advantage of using native browser features that WebDriver inherently promotes.
  • Xpath tend to become complex and hence make hard to read in my opinion
However there are some situations where, you need to use xpath, for example, searching for a parent element or searching element by its text (I wouldn't recommend the later).

If you know css selectors, those are much more easier (and will work fine with IE without any problem ) than xpath even though they can't replace entire xpath.


Consider below HTML tags


 <div id="firstDiv">This div tag has static id </div>

 <p id="paragraps_dynamic_1234">This p tag has dynamic id</p>

 <a onclick="doThat()" title="doThatOperation">This a tag has multiple attributes</a>

 <h1 name="heading1" value="headName">This is heading</h1>


<div>
<input type="text" id="username" name="username"
<input type="password" id="password" name="pwd"
</div>

<h2 id="propertyUserData">This tag is for starts-with example</h2>


Tag XPATH CSS SELECTOR
div "//div[@id='firstDiv']" "div[id='firstDiv']"
p "//p[contains(@id,'paragraps_dynamic_')]" "p[id*='paragraps_dynamic_']"
a "//a[contains(@onclick,'doThat') and @tile='doThatOperation']" "a[onclick*='doThat'][tile='doThatOperation']"
h1 "//h1[@name='heading1' and @value='headName']" "h1[name='heading1'][value='headName']"
input "//div/input[@id='username']" "div > input[id='username']"
input "//h2[starts-with(@id,'propertyUser')]" "h2[id^='propertyUser']"

By seeing above locators we can conclude some points regarding css selectors

  • Using css selector we can access particular node or immediate child of any node
  • Can combine as many conditions as we want for single node.
  • Can achieve starts-with, contains functionality using ^,* symbols respectively. 
  • We can't traverse back using css selector.
  • We can't go to  the siblings also (preceding as well as following)

Friday, May 16, 2014

What is selenium webdriver?

 What is selenium webdriver


What is selenium webdriver and how it help us in software testing process?

Webdriver in selenium (http://docs.seleniumhq.org/projects/webdriver/) is an Interface and it is designed to overcome some limitations of selenium RC software testing tool. However selenium WebDriver's development is in process so still there are few limitations and known issues available in selenium WebDriver. Selenium WebDriver is also known as Selenium 2 and used for web as well mobile
applications testing. It is freeware software testing tool and mostly used as a regression testing tool for web and mobile applications.
Selenium 2 supports most of all browsers to run your test cases and many programming languages like C#, Java, Python, Ruby, .Net, Perl, PHP, etc.. to create and modify your test scripts. Selenium 2(WebDriver) controls browser directly from operating system level so it is interacting very fast and with more realistic way with browsers. Major people in world using Selenium webdriver with java.

What are difference between Selenium IDE, RC and WebDriver

Selenium IDE
Selenium RC
Selenium WebDriver
It only works in Mozilla browser. It supports with all browsers like Firefox, IE, Chrome, Safari, Opera etc. It supports with all browsers like Firefox, IE, Chrome, Safari, Opera etc.
It supports Record and playback It doesn’t supports Record and playback It doesn’t supports Record and playback
Doesn’t required to start server before executing the test script. Required to start server before executing the test script. Doesn’t required to start server before executing the test script.
It is a GUI Plug-in It is standalone java program which allow you to run Html test suites. It actual core API which has binding in a range of languages.
Core engine is Javascript based Core engine is Javascript based Interacts natively with browser application
Very simple to use as it is record & playback. It is easy and small API As compared to RC, it is bit complex and large API.
It is not object oriented API’s are less Object oriented API’s are entirely Object oriented
It doesn’t supports of moving mouse cursors. It doesn’t supports of moving mouse cursors. It supports of moving mouse cursors.
Need to append full xpath with ‘xpath=\\’ syntax Need to append full xpath with ‘xpath=\\’ syntax No need to append full xpath with ‘xpath=\\’ syntax
It does not supports listeners It does not supports listeners It supports the implementation of listeners
It does not support to test iphone/Android applications It does not support to test iphone/Android applications It support to test iphone/Android applications

Load Testing: What is it?

In this article we are going to see what is Load testing and how to do it. I will try to discuses about strategy to perform Load testing. In my other Load test tool specific post, I will explain how to implement a load test.

Load testing is the process of putting demand on a system or device and measuring its response. In case of software, the demands will be the functions which are needed to be performed and our system will have to perform those. For example,A load test will define and measure a computer/ peripheral/ server/network /application's maximum level of work of its specifications.

The primary goal of load testing are -

-To define the maximum amount of work a system can handle without significant performance degradation
-For comparing capabilities and accuracies of a system with other systems (under controlled lab conditions).
-To get idea about the system on how it functions in real life.
-To get different type of report for having a overall idea on a new or legacy system.

There are mainly two type of load testing can be performed

A. Longevity testing : This will measure the system's ability on how long the system performs on standard operations(standard load). The main focus will be on how long(the time) the system is stable and consistent.

B.Volume testing : This will measure the system's ability on how the system is stable on heavy operation(heavy load) in standard time. The main focus will be the volume of the operations(load) that system can handle. This load may be performed by multiple users.

Both have pinpoint bottlenecks, bugs and component limitations. EX-A mobile may have a fast processor but a limited amount of RAM (memory). Load testing can provide us with a general idea of
-how many applications or processes can be run simultaneously while maintaining the rated level of performance.
-How long the mobile will be stable with operating standard applications.
-How many users can use the application's certain function (if it is a mobile app using web service)

To perform a load test you may go through following steps
-Define the functions to be perform for the load test .
-Define the time for performing the functions.
-Make a bottom line standard system behavior to define the bugs/issues(like , set a time for perform some operation or set some operations to run for certain period of time)
-Define the measuring parameters(what to monitor)
-Choose suitable reports(grid results, charts, graphs etc) to monitor the results.
-Choose alert/marking type to determine alarm points(defining bugs).
-Choose tools meeting the above requirements.

For different scenarios, load testing measuring parameter can be different. 
For a desktop/mobile application (not using data network)
-Use of processor/memory/time on certain functions.
For a web application/service/data server/applications using internet(desktop/mobile)
-Amount of time on certain functions.
-Number of users concurrently can use certain functions.
-Number of functions can be used in certain time

Some load test tools are :
a. JMeter
b. Load UI
c. Load Runner
d. Visual Studio Load test
e. Eclipse Load test tool 
f. SOASTA

Some Load testing areas are like
-Performing extreme process using functions(like complex logic operation, tree operations)
-Writing and reading data to and from a hard disk continuously
-Downloading a series of large files from the Internet
-Log in to a same system with large number of users.
-Exchanging big number and big size of mail in a mail server. 
-Downloading a series of large files from the Internet.
-Running multiple applications on a computer or server simultaneously.
-Assigning many jobs to a printer in a queue.
- Large amount of permission concurrently occurs as accepted/rejected/filtered.  

.... I will try to increase the more load test areas incrementally....

Thanks.....:) 

Tuesday, May 13, 2014

How run JMeter in different modes?

How run JMeter in different modes?

In this article we are going to learn how to run JMeter in different mode or ways. This is introductory article for novice users.

After downloading JMeter , in the bin directory if we run

jmeter.bat [Run JMeter with GUI]
jmeter-n.cmd [run a non-GUI test dropping a JMX file]
jmeter-n-r.cmd [run a non-GUI test remotely dropping a JMX file]
jmeter-t.cmd  [drop a JMX file on this to load it with GUI]
jmeter-server.bat [start JMeter in server mode]
mirror-server.cmd [runs the JMeter Mirror Server in non-GUI mode]
shutdown.cmd [Stops a non-GUI instance gracefully]
stoptest.cmd - [Stop a non-GUI instance abruptly]

Note: the special name LAST can be used with jmeter-n.cmd, jmeter-t.cmd and jmeter-n-r.cmd and means the last test plan that was run interactively.

We can override JVM settings using JVM_ARGS in the jmeter.bat script.
For example:
set JVM_ARGS="-Xms1024m -Xmx1024m -Dpropname=propvalue"
jmeter -t test.jmx ... 
 
To edit the jmeter shell script using JVM_ARGS(if JVM options are not supported by current JVM) For example:
JVM_ARGS="-Xms1024m -Xmx1024m" jmeter -t test.jmx [etc.]

This two i have not used yet, but I am configuring JMeter for my current work, so when ever I have finished, I will add an example with changed environment variable(JVM_ARGS)

There is another way to run jmeter in expert mode . If we edit the following line as true and enable it in jmeter.properties file. It will work.
-To Turn expert mode on/off [It will show expert-mode beans and properties]
jmeter.expertMode=true

Thanks...:)

Localization Testing

What is L10N testing(Localization)? How to do it

In this article we are going to learn about L10N (Localization)testing and how to do that.

What is localization? Localization is a term in software that refers to support any language, any location culture. We can easily understand by the meaning of supporting different language, but what is location culture. This location culture means, the culture format of any geographical location such as Date format, Time format, currency format, number format etc. This is a vital issue when we need to deploy a world-ready software. It is also known as L10N testing

Localization translates UI (may changes some initial settings) to make it suitable for another region. Localization Testing checks the quality of a product for a particular Location/culture. This test is based on the results of globalization testing(verifies the functional support for that particular culture/locale). Localization testing may be done with a localized version of a product. Localizability testing does not focused on testing localization quality.The test focuses on:
- Affected Areas by localization(UI/content)
- Culture/locale-specific, language-specific, and region-specific areas

But, these should be included in localization testing :
-Checking Basic functionality
-Deployment(spatially Setup /upgrade) tests under localized environment. For OS, we should select any language version of Windows/Linux as a platform for the test after installing the target language support or that language specific OS(like Japanese XP).

 Popular Scopes for localization testing :
-Check application resources and attributes
-Check linguistic accuracy (correctness)
-Check linguistic meaning (following culture)
-Check typographical errors.
-Check that documentations, online Help, messages, interface resources, and command-key sequences are consistent/sync with each other. If localized versions of the product exist , check the translation is consistent with previous release.
-Check dependency to system/input/display environment standards.
-Check usability of the UI.
-Check sensitive content(political/religious etc)
-Check your company identity is correct.(market-specific information about your company like contact information or local product-support phone etc).

Some known types of checking for application resources
Checking Content – Static & dynamic content such as product catalogs, search results, etc.
Checking Dates – Is the date January 1 or 1 January or 1st Jan.
Checking Characters/symbols – Different languages have different sets of characters.
Checking Postal codes – In some countries, postal codes contain letters.
Checking Phone numbers – Different formats for different markets.
Checking Direction – Some languages are written left to right, other languages are right to left.

I used to make checklist before doing . My sample localization testing checklist:

- Spelling Rules
- Sorting Rules
- Searching Rules
- Upper and Lower case conversions
- UI Sizes
- Printers
- Size of Papers
- Operating System
- Key boards
- Text Filters
- Hot keys
- Mouse
- Date formats
- Measurements and Rulers
- Currency format, value separator,currency symbol
- Country related codes(phone/postal/country/state name and code)


...I will try to include more testing scopes incrementally..

How to Perform load test using Jmeter

In this article we are going to see very simple steps to perform load test on a site. For basic idea about jmeter, please see my this post.

Step 1 : Download latest JMeter from this link 
Step 2 : Extract and Run jmeter.bat from bin(my case, C:\apache-jmeter-2.8\bin)
Step 3: Add thread group and provide some user , time and loop counter(I use 10 user, 2 second and loop count 3). Here we have to use as for requirement. Suppose, Client want the load 1000 user. So, for that if we have very fast PC, we can use 1000 user in 1 second. But it is better to increase the number of user with little more time which creates less load to the PC. In this case , 1000 users in 10 seconds.

 
Step 4 : Right click on Thread group and add a sampler "HTTP Request"
Step 5 : Provide the link of your site.( I use www.kaz.com.bd for test) as server name
Step 6: Right click on Thread group and add some Listeners (to view report).
 
I have added
View Results Tree
View Results in Table
Graph Results
Monitor Results
Aggregate Report
Comparison Assertion Visualizer
Response Time Graph
Summary Report

Step 7 : Run the test. 
You can see/save the report and get you test done