Friday, March 22, 2013

PRACTICUM: Selenium 2 Testing Tools Beginner's Guide: Advanced User Interactions


This is the next installment (in progress) of my PRACTICUM series. This particular grouping is going through David Burns' "Selenium 2 Testing Tools Beginner's Guide".

Note: PRACTICUM is a continuing series in what I refer to as a somewhat "Live Blog" format. Sections may vary in time to complete. Some may go fast. Some may take much more time to get through. Updates should be daily, they may be more frequent. Feel free to click refresh to get the latest version at any given time. If you see "End of Section" at the bottom of the post, you will know that this entry is finished :).


Update: This project was put down back in April, with the intention to get back to it after I figured out why the examples weren't working. I didn't intend for the process to take 3 MONTHS to get back to, but I believe in finishing what I start, whenever I can. Therefore, all of the previous examples from earlier posts have been updated and re-examined. thanks for the patience and here's hoping you all continue the journey with me once again :).



Chapter 9: Advanced User Interactions


Much of what we have worked with thus far would be plenty if the web of yore were the one we were working with. Ahh yes, those days when things were simple. Three tiered architecture, some simple front end details, links, buttons, and a few CGI scripts. Just find the elements, click the buttons or links, and move to the next item. So simple... and so 1994!

The web doesn't really look like that any longer. Well, many places actually still do, but the places we most like to visit certainly don't. Today's Twitter and Facebook level web apps are a lot more dynamic. It's not just typing text and clicking buttons. Now we can move stuff, resize things, pull and stretch and add components whenever we feel like it, and who knows what will happen next.

For these types of environments, this next chapter focuses on how the user can leverage more advanced options in the API to have this level of interaction. These interactions require a more in depth coverage of not just keyboard combinations, but actual placement and movement of the mouse, and how to track it and implement the appropriate actions.

Creating an Action Chain

One of the things that we are ab;e to do with Selenium is create sequences of events that we can bind together. These sequences are referred to as "action chains" and they allow us to  make a variety of movements and treat them as one action. Below is the example code that David presents to show us how to drag and drop an element:


If we run the text, we should see two things happen. The first is we should see a screen like the first one below:



and then see a second screen that looks like this:



I say "should because, well, that's not what I'm seeing. Instead, my browser looks like this:

And my output for the test looks like this:



Now, if I have learned anything from these past several weeks, it's not to jump to conclusions that something isn't working. It's very possible that what may be the culprit is the version of Java JDK I'm using. My plan is to dig in and see if there's some thing I'm unaware of. For the Java pro's out there, if I'm doing something dumb, please, let me know so that I can fix it :).

Moving an Element by an Offset Value

So, the building option to allow us to move elements also allows us to move items by specific amounts (or so the book says). With this is n mind, I tried to create the example as described, using JUnit 4.1.1 format. Instead of dragging and dropping abox from one element to another, this time, it calls for moving by an index amount on the X-Y axes.



Seems straightforward enough, but I am still seeing the same issues with this example as with the last one.



Again, Java peoples out there, it is just me, or is there something not happening here that should be happening? An enquiring mind wants to know.

More to come. Stay tuned!

Michael Larsen, TESTHEAD
Post a Comment