PyCon 2014

Técnicas avanzadas para crear tests funcionales para aplicaciones web

Julien Phalip  · 




Extracto de la transcripción automática del vídeo realizada por YouTube.

good afternoon everyone now we have my friend Julie envelop with from San Francisco and he'll be talking about advanced techniques for web functional testing Julian thank you and thanks everyone for coming today I'm going to start just very briefly

don't want to bore you with that just couple facts about me so you know why I'm here today I've been happily programming with Python as my main language for a number of years I am also a jungle core committer and I occasionally tweet from this

angle if you're ever interested in what I have to say I work at neuron we are a web agency with a few offices scattered scattered around the world I'm personally based in San Francisco but we also have an office here in Montreal and we do really good

work and we encourage you to check out our website or come and see me after the talk if you like to learn more about us okay so starting with a few definitions just so we're clear on what I'm going to be talking about when we talk about unit testing

it is to ensure that small parts of our code each work in isolation integration testing is about ensuring that some of those parts when combined together keep working well and then functional testing is one step beyond is when you want to make sure that you

application as a whole functions well in particular from a user's perspective and one we do with functional testing for the web typically it comes down to using browser automated now why would be using browser or tomatoes first because it brings us closer

to real web user environment all the median static files such as CSS images etc they automatically get loaded by the browser you don't have to worry about any of that and similarly any JavaScript code any age of course implicitly get executed by the browser

and then when all that is put together then it allows you to test user interactions browser compatibility and very importantly it's a lot of fun now the the most most likely the most popular web browser Automator are there these days is selenium I was

actually curious today who of you have ever used selenium if you could raise your hand well that's clearly the majority that's exciting and really hope that as you walk out with this doc you actually learn a lot of new tricks so selenium very briefly

implements the webdriver API which is about to become the WTC w3c standard and it's currently in draft it works across multiple browsers for example firefox chrome IE safari and opera it has client libraries in verse languages in particular python that's

what we're interested in and it's very 0 install you just run pip install selenium and off you go so for those of you who do not know about selenium a photo just give very quick demo just to get an idea of the kinds of things that you can do with it

so here I'm just going to run a subset of the Django admin test read which is written with selenium I'm going to be holding my hands up so you know that it's automated I'm not going to do anything everything is going to be running by itself

what's going to happen is that you will see an instance of Firefox that will open and then a bunch of user action being executed in an automated way so here you see Firefox is running running a bunch of user action and it's all going very fast here

typically we using selenium in Django mostly to test the functionality so that means forms midships false emissions and JavaScript any little JavaScript tidbits that help improve the experience in the Django admin so we didn't want to have some tests to

make sure that as we keep adding more code to JavaScript or even in the Python code sometimes just make sure that everything keeps working that there are no regression over time so that's it just to give you an idea of the kinds of stuff that you can do

with selenium now then I thought that I show a few things that may not necessarily be obvious when you start using selenium if you for example you you you've created responsive websites which responsiveness something that's become really popular in

the last couple of years and for good reasons because with a single code base you can display content optimally for very screen sizes for example for mobile or desktop or tablet now testing your website we see liam is actually really really simple it all comes

down to using that one method which comes in the webdriver API set window size which allows you to at any point in time during your test to resize the browser window and then for example you may stop with 600 pixel width run some tests make sure everything

works for mobile and then expand the window size 2 then run some tests to make sure that you're worse on desktop and I just had a very simple demo here again to do that i actually used the pipe con website which which i'm sure you've all used and

interacted with i'm just currently running it locally so it actually happens to be a jungle side too and if you look here at the top for example there's a menu which you can expand is very you know traditional kind of interaction and he resize the

[ ... ]

Nota: se han omitido las otras 2.476 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.