GUI Testing Tool – Selenium

Posted on

Selenium is one of the most commonly used testing tool for Web-based applications. Selenium first started with the automation testing library in JavaScript written by Jason Huggins in 2004 and the library became Selenium Core, which underlies all the functionality of Selenium IDE and Selenium Remote Control. The latest release for Selenium server is 2.11. Selenium supports test scripts written in Java, C#, Ruby, Python, Perl, PHP and .Net. Selenium tests run directly in an supported browser, including IE, Firefox, chrome, and Safari.

What to test?

  1. Static Page Content: verify anything in static source code like title, footer, images.
  2. Links: check if the link is a broken link and if expected page returned with the link.
  3. Functionality: test user response with defined inputs. Typical tests can be for user login/registration to, user account operations, backend data retrieval operations, etc. User input can be via any browser-supported input fields, like text input boxes, check boxes, drop-down menus, etc.
  4. Dynamic Elements: test if the dynamic result is generated based on the specific user action.
  5. Ajax Tests: check if the content is returned after a certain time period. The best way to locate and verify an Ajax element is to use the Selenium 2.0 WebDriver API.

Ways to test?

Selenium provides a test suite to fit different kinds of testing requirements.

  • Selenium IDE
    Selenium IDE is a browser plugin which allows you make your test cases or test suites manually or using the record and play feature. Current highest stable release for Firefox 7.0.1, and Selenium IDE 1.4 supports Firefox 8. It is better to generate and test your test cases/suites in Selenium IDE before running them in the Selenium server.You can import and export test cases/suites in different programming languages.

  • Selenium 1 (Selenium RC)
    Selenium Remote Control server serves as the intermediate server between the client browsers and the client language libraries. Most test cases extend the SeleneseTestCase in the com.thoughtworks.selenium package, which is marked as deprecated. It is recommended that you use the Selenium 2 and WebDrive instead.Use “java -jar [absolute_path_to_seleniumServer]” to start Selenium server and Ctrl+C to stop it. If you double click to start the server, try this URL to stop it: http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

  • Selenium 2.0 and WebDriver
    Selenium 2 is a way to test all of these different web browsers without having to install Selenium Core on the web server since it has been bundled with Selenium RC so it can act as a proxy server between the testing application and the test script.

    You can run the testcase with notations as JUnit Test or run the WebDrive as Java application in your IDE. If you have JUnit jar file in your classpath, you can run JUnit tests in command prompt with this syntax:
    java junit.textui.TestRunner [-wait] TestCaseClass

    Test suite directly in command line prompt with syntax similar to below:java -jar selenium-server-standalone-.jar -htmlSuite "*firefox"
    "http://www.google.com" "[absolute_path_to_testSuite]"
    "[absolute_path_to_testResultFile]"

Reference:
1. Platforms Supported by Selenium
2. Selenium Documentation


JMeter Remote Testing on AWS EC2

Posted on

I have been trying to set up Apache JMeter remote testing the last few days. JMeter remote testing enables users to view the test results on a client machine while the traffic is generated from one or more other servers. It is useful when you want to view the test result on a lower spec server and generate huge amount of traffic with a higher spec server or a cluster.

Initially, I was hoping that I can set up the JMeter server on AWS EC2 and the client on my laptop. Unfortunately, that didn’t go well and I was having inconsistent error messages. After that, I tried to set up on both of my laptop. I have googled for solutions and tried changing the port numbers for the server and rmi, turning off the firewalls on both sides, and telnetting to each other. And I was having a socket error message. My third experiment was to set up this remote testing on two EC2 (Windows Server 2008 R2) instances and it finally works. Below are the steps that I took to set up JMeter remote testing.

  1. Launch two EC2 instances
  2. Download and install JDK, JRE, JMeter (binary package) on both instances. JMeter requires JVM 1.5 and above.
  3. On the server, double click the jmeter-server.bat in [JMETER_HOME]/bin folder. A command prompt window similar to below will pop up.
  4. On the client side, you need to add the IP address of the server to the “remote_hosts” property in the jmeter.property file in [JMETER_HOME]/bin folder. You can use either private IP address or the public IP address but the public IP address changes every time you restart your instance. To start the JMeter client with GUI, double click the jmeter.bat in [JMETER_HOME]/bin folder. After adding a simple thread group with a listener, we can start the remote testing by selecting the IP address of the JMeter server from the Remote Start menu.

    After you start the test. You should see a message similar to the one below shows up on the command prompt.
  5. On the server side, you should receive the messages for starting and finishing the test.

I am happy that I finally have it set up after many tries. I still don’t know if there are fixes for my first two tries. Please leave a comment if you have the same issues or know about how to fix them.

Full list of command line options: http://jakarta.apache.org/jmeter/usermanual/get-started.html#options