Wednesday 8 June 2011

How Can I use Selenium RC in remote control

Yeah !

Here, Selenium RC in remote can be possible via Xvfb ( X server virtual Buffer). This can be also used in hudson througth ant script.
Test-remote Documentation

Ubuntu server running Hudson (software for Continuous Integration), we may want to make a first attempt to run a Selenium test suite in command line before setting up a Hudson job that automatically runs the test suite.

Xvfb(X Virtual Frame Buffer) for Selenium RC in Amazon.
Opearting System

1. Ubuntu 10.04

Set up a Virtual Display with xvfb

* Download xvfb, by running in a local box terminal

sudo aptitude install xvfb

xvfb is normally installed in /usr/bin/xvfb

* Attempt to test the Xvfb using something like:

Xvfb :99 -ac


* It will most likely see a long list of error messages, something like:

[dix] Could not init font path element /usr/share/fonts/X11/misc, removing from
list!
[dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing
from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled,
removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled,
removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/Type1, removing
from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing
from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing
from list!
sh: /usr/bin/xkbcomp: not found
(EE) Error compiling keymap (server-42)
(EE) XKB: Couldn't compile keymap
[config/dbus] couldn't take over org.x.config:
org.freedesktop.DBus.Error.AccessDenied (Connection ":1.74" is not allowed to
own the service "org.x.config.display99" due to security policies in the
configuration file)


For removing above error should run the below commands:

* Run:

sudo aptitude install x11-xkb-utils

* The font issues, probably, do not require fixing from a functional standpoint; nonetheless, you can install them with the following command:

sudo aptitude install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

* Some of the required components of this fake X server are within the core package of the actual X server. Try installing:

sudo aptitude install xserver-xorg-core

* These four steps enabled 10.04 Ubuntu server to run Xvfb. I tested the xvfb-run command like:

xvfb-run firefox

* It launches the firefox browser (if installed, if not installed it just exits) and waits for you to CTRL+C cancel it

Now, the Xvfb Successfully installed on your local box.
Verifying the installed Xvfb

* run below command to know Xvfb installed or not.

sudo dpkg-query -W -f='${Status} ${Package}' xvfb

* The output should be

install ok installed xvfb

Execution

* For Execute xvfb to specify the display we will use

/usr/bin/Xvfb :7 -ac -screen 0 1024x768x8

7 makes xvfb use display 7

-ac Disables access control to the X server, enabling access by any host (Useful for running test suites remotely)

-screen 0 1024x768x8 creates screen 0 on the chosen display (7) at resolution 1024x768 and 8-bit color depth.

* After you installed and configured xvfb to use a specific display

In another terminal, set the DISPLAY variable to use the display you configured with xvfb:

export DISPLAY=":7.0"

* Execute the command

java -jar selenium-server.jar -htmlSuite *[browser] [initial address] [test suite location] [test result html file for results]

* Example

java -jar /path/selenium-remote-control-1.0.3/selenium-server-1.0.3/selenium-server.jar -htmlSuite *firefox "http://www.google.com" "/path/TestSuite.html" "/path/sampleresult.html"

Download the Test Suite

TestCase


* Output will be:

21:10:01.094 INFO - Java: Sun Microsystems Inc. 19.1-b02
21:10:01.098 INFO - OS: Linux 2.6.32-31-generic i386
21:10:01.196 INFO - v2.0 [a2], with Core v2.0 [a2]
21:10:01.709 INFO - RemoteWebDriver instances should connect to: http://192.168.1.10:4444/wd/hub
21:10:01.712 INFO - Version Jetty/5.1.x
21:10:01.714 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
21:10:01.716 INFO - Started HttpContext[/selenium-server,/selenium-server]
21:10:01.716 INFO - Started HttpContext[/,/]
21:10:01.848 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@e80842
21:10:01.849 INFO - Started HttpContext[/wd,/wd]
21:10:01.857 INFO - Started SocketListener on 0.0.0.0:4444
21:10:01.857 INFO - Started org.openqa.jetty.jetty.Server@17bd6a1
21:10:02.317 INFO - Preparing Firefox profile...
21:10:05.722 INFO - Launching Firefox...
21:10:08.374 INFO - Checking Resource aliases
21:13:44.301 INFO - Checking Resource aliases
21:13:44.303 INFO - Received posted results
21:13:45.803 INFO - Killing Firefox...
Tests Passed, see result file for details: Desktop/Result.html

Thursday 31 March 2011

How can I Test Back-end API in Jmeter?

Its Just a very simple, backend API can run using Jmeter. It will give exact performance report. Jmeter also used for finding fornt-end performance. Here, the simple requirement for running backend API in Jmeter. First, we required to set Cookies. Cookie handle with Http Cookie Manager and cookie policy in Jmeter.