Web testing from Python scripts?

17 views
Skip to first unread message

Pierre Thibault

unread,
May 23, 2011, 1:00:44 AM5/23/11
to montrea...@googlegroups.com
Hello,

I would like to know if you are using a Python tool to simulate an http browser client from a Python script. I am looking for a tool to do just that to test web applications so I would appreciate advice on the subject.

--


A+

-------------
Pierre
My blog and profile (http://pierrethibault.posterous.com)
YouTube page (http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2)

Michael Tobis

unread,
May 23, 2011, 6:15:04 PM5/23/11
to montrea...@googlegroups.com
Selenium. http://seleniumhq.org/about/

mt
--
Michael Tobis
Cote St Luc QC
Austin TX

Pierre Thibault

unread,
May 23, 2011, 9:22:22 PM5/23/11
to montrea...@googlegroups.com

Selenium is for web gui testing only, right?

I made a little search and I found two tools that I will probably try:

http://www.getwindmill.com/ WindMill is a tool similar to Selenium. I don't know more at the moment.

http://funkload.nuxeo.org/intro.html is another tool. This one is for loading testing and integration testing. Funkload is able to simulate an http client just like I wanted. I haven't dig yet.

init_null

unread,
May 23, 2011, 9:40:17 PM5/23/11
to montrea...@googlegroups.com
not in python but JMeter is very good.

--
Gabriel Tremblay B.Ing
http://www.etrange.ca/view



--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Montréal-Python.
Pour envoyer un message à ce groupe, adressez un e-mail à montrea...@googlegroups.com.
Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse montrealpytho...@googlegroups.com.
Pour plus d'options, consultez la page de ce groupe : http://groups.google.com/group/montrealpython?hl=fr-CA

Joël Perras

unread,
May 23, 2011, 10:33:33 PM5/23/11
to montrea...@googlegroups.com
If you want to be able to do programmatic front-end testing (e.g. fetch a page, test if certain HTML tags exist), then there are a few tools to do that. However, the difficult part comes in when you want to test that dynamic content (e.g. ajax calls on mouse events, drag & drop, etc.) functions correctly.

As far as I know, there exist no such tools in Python, since you need both a javascript runtime as well as a DOM implementation to simulate events and the various rendering quirks of modern browsers. You can always go with something like Selenium (which has been mentioned previously by Pierre), which does the job relatively well. 

If you're a bit more adventurous, the Javascript community has done a great deal of work in this area. Most notably:


And  there are probably some more that I've forgotten about.

Hope that helps.
Joël.
-- 
I do know everything, just not all at once. It's a virtual memory problem.
You should follow me on Twitter: http://twitter.com/jperras

Yannick Gingras

unread,
May 24, 2011, 9:05:04 AM5/24/11
to montrea...@googlegroups.com

On 2011-05-23 22:33 Joël Perras wrote:
> [...]

With two replies in less than a week, it's obvious that you are
subscribed to this list.

Joël, have you started coding in Python? We love to see famous PHP
hackers giving our little brace-less language a try.

--
Yannick Gingras
http://ygingras.net

signature.asc

Marc-Antoine Ruel

unread,
May 24, 2011, 2:47:58 PM5/24/11
to montrea...@googlegroups.com
Le 23 mai 2011 18:15, Michael Tobis <mto...@gmail.com> a écrit :
Selenium. http://seleniumhq.org/about/

Mechanize works well in simple cases.

For complex issues, like authentication done with javascript (I hate you Videotron), selenium works much better, since it's a real browser but is way slower. I think you can use xvfb+icewm if you don't want UI to show up.

M-A

Joël Perras

unread,
May 24, 2011, 3:02:35 PM5/24/11
to montrea...@googlegroups.com

On 2011-05-23 22:33 Joël Perras wrote:
[...]
With two replies in less than a week, it's obvious that you are
subscribed to this list.
You caught me! :-P 


Joël, have you started coding in Python? We love to see famous PHP
hackers giving our little brace-less language a try.
I've been writing python for little while now, and it's quite the pleasure. I've mostly been doing client work that required some natural language processing and recommendation-engine type things, and had zero motivation to re-learn Java to do it. Python, of course, was the natural choice. I'm hoping to find reasons to do more python on a day-to-day basis. 

I'll most likely be releasing a good chunk of stuff open source as well; I'd love to get some feedback on my code, since I'm still learning some of python's idiomatic constructs. Here's a simple little hack that I whipped up for some database (mongodb) profiling I needed to do for a client: https://github.com/jperras/mongo-profiling

Anyways, I'm looking forward to attending some of the sprints/meetups that the Montréal python group hosts. You all seem to do some very awesome stuff.

Sorry for inadvertently hijacking the thread ;-).
Joël.

Pierre Thibault

unread,
May 24, 2011, 6:43:42 PM5/24/11
to montrea...@googlegroups.com
2011/5/23 init_null <init...@gmail.com>

not in python but JMeter is very good.

--
Gabriel Tremblay B.Ing
http://www.etrange.ca/view


LoadUI seems great too. http://www.loadui.org/index.php?js=off It is in Java too.

Pierre Thibault

unread,
May 24, 2011, 6:53:20 PM5/24/11
to montrea...@googlegroups.com
2011/5/23 Joël Perras <joel....@gmail.com>

If you want to be able to do programmatic front-end testing (e.g. fetch a page, test if certain HTML tags exist), then there are a few tools to do that. However, the difficult part comes in when you want to test that dynamic content (e.g. ajax calls on mouse events, drag & drop, etc.) functions correctly.

What I think that I will do is passing a parameter to my web application so it turns the result in a way that it is easy to analyze with a Python script.

For testing flow and GUI, I'll use something  like Selenium.

As far as I know, there exist no such tools in Python, since you need both a javascript runtime as well as a DOM implementation to simulate events and the various rendering quirks of modern browsers. You can always go with something like Selenium (which has been mentioned previously by Pierre), which does the job relatively well. 

If you're a bit more adventurous, the Javascript community has done a great deal of work in this area. Most notably:


And  there are probably some more that I've forgotten about.

Glad to know that these things exists.
 

Hope that helps.
Joël.


I'll come back to tell you about the solution I found.

It is great to have community where you can ask these difficult questions.

Gustavo Barbosa

unread,
May 31, 2011, 12:07:35 AM5/31/11
to montrea...@googlegroups.com
Hi Pierre,

There is a very interesting tool called Lettuce (http://lettuce.it/). It is a Behavior Driven Development tool that you can use for GUI tests, for example. It is written in Python and includes Selenium actions to perform your browser tests.

Hope I helped you.

Hugs,
Gustavo Barbosa


2011/5/24 Pierre Thibault <pierre.t...@gmail.com>

Pierre Thibault

unread,
May 31, 2011, 8:37:22 AM5/31/11
to montrea...@googlegroups.com
2011/5/31 Gustavo Barbosa <gusta...@gmail.com>

Hi Pierre,

There is a very interesting tool called Lettuce (http://lettuce.it/). It is a Behavior Driven Development tool that you can use for GUI tests, for example. It is written in Python and includes Selenium actions to perform your browser tests.

Hope I helped you.

Hugs,
Gustavo Barbosa

Hi Gustavo,

This looks like an interesting tool.But how is it different from TDD (Test driven design)? From the project web's site:

The common BDD approach basically consists in:

  • writing some unit tests
  • running these tests
  • making these tests fail
  • writing code
  • making the code pass these tests (green status)
 

Simon Law

unread,
May 31, 2011, 10:42:00 AM5/31/11
to montrea...@googlegroups.com
BDD is a refinement of TDD.

The whole point is so that non-technical people can read the test plan, because it's written in a human-like domain specific language.

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Montréal-Python.
Pour envoyer un message à ce groupe, adressez un e-mail à montrea...@googlegroups.com.
Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse montrealpytho...@googlegroups.com.
Pour plus d'options, consultez la page de ce groupe : http://groups.google.com/group/montrealpython?hl=fr-CA



--

Gustavo Barbosa

unread,
May 31, 2011, 2:53:26 PM5/31/11
to montrea...@googlegroups.com
Exactly like Simon said !

You describe the behavior of your feature (so you can use human-like language), before you write some code.

For example:

Feature: Log in
Scenario: If I pass correctly the username and password, so I am at the main page.
    Given I am at login page
    When I log me in with username 'teste' and password 'test'
    Then I am at the main page

Then, you describe the functions that will respond to these statements.
In this case, you can use the selenium support that Lettuce offers to you.

BDD is basically a refinement of TDD. The question is.. if you have somebody (like a Product Owner in Scrum, or yourself) to write the feature behavior of your product, for example, you codify it by this way.

Hugs,
Gustavo Barbosa


2011/5/31 Simon Law <sfl...@sfllaw.ca>

Pierre Thibault

unread,
May 31, 2011, 3:08:59 PM5/31/11
to montrea...@googlegroups.com
2011/5/31 Gustavo Barbosa <gusta...@gmail.com>

Exactly like Simon said !

You describe the behavior of your feature (so you can use human-like language), before you write some code.

For example:

Feature: Log in
Scenario: If I pass correctly the username and password, so I am at the main page.
    Given I am at login page
    When I log me in with username 'teste' and password 'test'
    Then I am at the main page

Then, you describe the functions that will respond to these statements.
In this case, you can use the selenium support that Lettuce offers to you.

BDD is basically a refinement of TDD. The question is.. if you have somebody (like a Product Owner in Scrum, or yourself) to write the feature behavior of your product, for example, you codify it by this way.

Hugs,
Gustavo Barbosa


TDD is enough for me now but I can see the value on the context you are describing.

As I see, it is like fitness but it is more orientied to unit tests than function tests as fitness does. Right?

Simon Law

unread,
May 31, 2011, 3:24:56 PM5/31/11
to montrea...@googlegroups.com
On Tue, May 31, 2011 at 3:08 PM, Pierre Thibault <pierre.t...@gmail.com> wrote:
As I see, it is like fitness but it is more orientied to unit tests than function tests as fitness does. Right?

It's almost certainly for integration testing. I wouldn't use BDD for unit testing, where the overhead starts to outweigh the benefits.

From what I can see, the whole point is for non-technical people to understand how the test plans are automatically executed, since the code is also the documentation.

Gustavo Barbosa

unread,
May 31, 2011, 3:27:32 PM5/31/11
to montrea...@googlegroups.com
This is it !

Hugs,
Gustavo Barbosa


2011/5/31 Simon Law <sfl...@sfllaw.ca>
On Tue, May 31, 2011 at 3:08 PM, Pierre Thibault <pierre.t...@gmail.com> wrote:
--

Pierre Thibault

unread,
May 31, 2011, 3:37:12 PM5/31/11
to montrea...@googlegroups.com
2011/5/31 Simon Law <sfl...@sfllaw.ca>

OK so fitness is a tool in the same category than lettuce? 

Gustavo Barbosa

unread,
May 31, 2011, 3:56:00 PM5/31/11
to montrea...@googlegroups.com
Yeah. You can say it.

Here is an example of BDD'ing with FitNesse: http://vimeo.com/3323573

Hugs,
Gustavo Barbosa


2011/5/31 Pierre Thibault <pierre.t...@gmail.com>
--
Reply all
Reply to author
Forward
0 new messages