English 中文(简体)
Integration Testing for a Web App
原标题:

I want to do full integration testing for a web application. I want to test many things like AJAX, positioning and presence of certain phrases and HTML elements using several browsers. I m seeking a tool to do such automated testing.

On the other hand; this is my first time using integration testing. Are there any specific recommendations when doing such testing? Any tutorial as well?

(As a note: My backend code is done using Perl, Python and Django.)

Thanks!

最佳回答

If you need to do full testing including exploiting browser features like AJAX then I would recomend Selenium. Selenium launches a browser and controls it to run the tests.

It supports all the major platforms and browsers. Selenium itself is implemented in Java but that is not really an issue if it is being used to test a web application through its user interface.

Selenium tests are a sequence of commands in an HTML table, the supported commands are in well documented. There is also an IDE implemented as a Firefox plugin that can be used to record and run tests. However the test scripts created in the IDE can be used to drive tests against any of the supported browsers.

问题回答

Selenium is a good way to go. For using it with Perl then use the Test::WWW::Selenium CPAN module.

Here is one example from its pod:

use WWW::Selenium;

my $sel = WWW::Selenium->new( host => "localhost", 
                              port => 4444, 
                              browser => "*iexplore", 
                              browser_url => "http://www.google.com",
                            );

$sel->start;
$sel->open("http://www.google.com");
$sel->type("q", "hello world");
$sel->click("btnG");
$sel->wait_for_page_to_load(5000);
print $sel->get_title;
$sel->stop;

And here are some additional links which maybe helpful:

/I3az/

In this article, Noah Gift does a good job presenting three main alternatives for web app integration testing: Windmill, Selenium and Twill. Twill doesn t do Javascript, so that leaves Selenium and Windmill as your main possibilities; Gifts shows enough about what using each of them means, so you can choose.

One thing Gift doesn t mention is that Selenium is much more popular -- that s not obvious if you just web search each of the terms windmill and selenium, but that s because each gets (different numbers of;-) false hits. [windmill javascript] gives 325k hits, [selenium javascript] gives 1.2M hits, and this ratio is more representative. Anyway, the point is that, if you find them both equally easy and powerful enough for your needs, so that you have a hard time choosing one, then picking selenium (i.e., going with the crowd) may have advantages (more experts around, e.g. on SO to answer questions;-) wrt picking the somewhat less popular alternative.

You can also control selenium using Selenium-RC s python binding. For example:

from selenium import selenium
selenium = selenium("localhost", 4444, "*firefox",
            "http://www.google.com/")
selenium.start()
selenium.open("/") # open google.com
selenium.type("q", "selenium rc")
selenium.click("btnG")
selenium.wait_for_page_to_load("30000")
selenium.failUnless(selenium.is_text_present("Results * for selenium rc"))
selenium.stop()

Selenium is a very good tool to automate browser testing

Since you mentioned Ruby in your tags, I also recommend Webrat which is a nice in-browser testing solution in Ruby.

Here s another option, all written in Python and cross browsers for running AND recording tests: Windmill

I would also recommend Selenium. It got a really nice Firefox Plugin, that you can use to create your integration tests.

TestPlan is a great tool for general purpose web testing. It provides both a display-less backend and Selenium. The Selenium backend should take care of testing in all the popular browsers. It also has its own scripting language which makes it quick to write and test, though Java can also be used.

For example, this goes to a page and submits a search form and checks that it found the correct result.

GotoURL http://myapp.com/

SubmitForm with
  %Params:search% some term
end

Check //div[@id= results ][contains(text(), some term ]

Another great tool for browser testing which is built as Ruby library and uses Ruby for scripting is Watir. There is also a firefox plugin for watir just like selenium called
Firewatir hosted on google code





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签