| Develop web testcases using Selenium IDE in Firefox for Joomla! |
|
|
| Saturday, 12 April 2008 12:53 | |||||||||||||||
Page 1 of 2 The quickest way to learn Selenium is via a Firefox plugin called Selenium IDE. It is quite compelling There are two modes of operation for Selenium - Core and Remote Control (RC). Remote Control This tools is able to:
Selenium is made of 3 components:
Also don't use Selenium for load testing web applications!, use Apache JMETER instead. Attention Selenium Today let just try Selenium IDE To make it work with Joomla!, or with any other web applications, just install the Firefox plugins, and start Lets say that we want to test the contact page of my site for proper operations...In Firefox, go to the menu Tools This will open a floating windows, which let you define a script step by step in the windows Script You may come with a test case similar to the one presented here: The number of commands is huge, but well documented in the tab reference (B) The base URL is my site (http://www.waltercedric.com), the test case, open the contact page, check the The menu and you see every step of the test case in the browser windows: As you see it is quite easy to develop a script to test a page, test can be saved on disk in different format, So the test developed for testing the contact page of Joomla! now look like: 1: package com.example.tests; 2: 3: import com.thoughtworks.selenium.*; 4: import java.util.regex.Pattern; 5: 6: public class NewTest extends SeleneseTestCase { 7: public void setUp() throws Exception { 8: setUp("http://www.waltercedric.com/", "*chrome"); 9: } 10: public void testNew() throws Exception { 11: // selenium.("http://www.waltercedric.com/-contact-me.html"); 12: assertEquals("Contact - Cedric Walter", selenium.getTitle()); 13: selenium.type("contact_name", "cedric"); 14: selenium.type("contact_email", " This e-mail address is being protected from spambots, you need JavaScript enabled to view it "); 15: selenium.type("contact_subject", "Selenium is great, try it"); 16: verifyTrue(selenium.isTextPresent("Enter your Message:")); 17: selenium.type("contact_text", "Hi Cedric. selenium would be cool for testing securityimages!"); 18: verifyTrue(selenium.isTextPresent("Send")); 19: selenium.submit("emailForm"); 20: selenium.waitForPageToLoad("30000"); 21: } 22: } Or better in PHP so you can reuse it in XINC continuous integration server (more to come on XINC in a future article) 1: <?php 2: 3: require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; 4: 5: class Example extends PHPUnit_Extensions_SeleniumTestCase 6: { 7: function setUp() 8: { 9: $this->setBrowser("*chrome"); 10: $this->setBrowserUrl("http://www.waltercedric.com/"); 11: } 12: 13: function testMyTestCase() 14: { 15: // $this->("http://www.waltercedric.com/-contact-me.html"); 16: $this->assertEquals("Contact - Cedric Walter", $this->getTitle()); 17: $this->type("contact_name", "cedric"); 18: $this->type("contact_email", " This e-mail address is being protected from spambots, you need JavaScript enabled to view it "); 19: $this->type("contact_subject", "Selenium is great, try it"); 20: try { 21: $this->assertTrue($this->isTextPresent("Enter your Message:")); 22: } catch (PHPUnit_Framework_AssertionFailedError $e) { 23: array_push($this->verificationErrors, $e->toString()); 24: } 25: $this->type("contact_text", "Hi Cedric. selenium would be cool for testing securityimages!"); 26: try { 27: $this->assertTrue($this->isTextPresent("Send")); 28: } catch (PHPUnit_Framework_AssertionFailedError $e) { 29: array_push($this->verificationErrors, $e->toString()); 30: } 31: $this->submit("emailForm"); 32: $this->waitForPageToLoad("30000"); 33: } 34: } 35: ?> As soon as You have a set of tests, this can form a Test Suite. SecurityImages for Joomla create Captcha, so it is quite difficult for a tool to pass the Turin test Read more at:
Powered by !JoomlaComment 3.20
3.20 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."
|
|||||||||||||||
| Last Updated ( Sunday, 13 April 2008 19:10 ) | |||||||||||||||
| Another articles: |
|---|
|


























yes it should be if ($hasSecurityIma...
components\com_maxcomment\max...
use search of my site, there is more ...