Talking testing, agility and automation... and anything else.



11
Dec 16

Chrome Hangs During Protractor Test Runs On Ubuntu

light-bulb-idea-icon-clipart-panda-free-clipart-images-h1fryo-clipartQuick Tip: I run Protractor tests, headlessly via XVFB, on a Ubuntu server (blog post on this to come), and was seeing Chrome annoyingly hang during test runs. I was constantly having to manually kill the chrome processes, and also an associated BrowserBlocking process. After a bunch of debugging, and searching, I finally found the solution. This simple env var fixes it:

Just add that to your .profile file, and you should be good to go.


16
Nov 14

Screencast: Protractor Test Automation Framework Example Code

I’ve been playing around with Protractor, a great, new(ish) testing framework from our friends at Google. I’ve shared my example code on GitHub for those that might be interested in such things.

Examples in the code include:

  • Using page objects
  • Running on TravisCI
  • Running tests on Sauce Labs and Browserstack
  • Running multiple browsers at once

I’ve also made a quick screencast that walks you through downloading and running the example code.

Cut to the chase, in the video we:

  • Install Node (okay, I don’t show this but you need do to it!)
  • Download the example code from GitHub
  • run npm install to install the project dependancies
  • Briefly discuss a config file
  • run protractor conf.js to run the tests

07
Jan 14

Geb vs. Sahi vs. Selenium-Webdriver

gebAs an addendum to my original post comparing Selenium and Sahi, I offer the same test written in Geb.

Sidebar:
I took a bit of flack for the original article, mainly people complaining that my comparison wasn’t an apples to apples comparison. Their argument was that because they share a more similar architecture, a more fair comparison would be to compare Sahi to Selenium RC. Of course this argument is complete rubbish. My comparison was (and is) merely a look into the raw code of each tool. But even if it wasn’t, Sahi and Selenium both aim to provide the same function: web application automation. Comparing these two tools is completely valid… though I do profess to enjoy the modicum of hyperbole. That all being said, I will paraphrase Mike Watt and say: “if you don’t like it, go out and start your own blog!”

Anyway, I’ll throw Geb’s hat in the same ring with one disclaimer: Geb runs on top of Webdriver… WORLD BEWARE. Please feel free to breath into a paper bag or the something…

Now, without further ado, I give you [gasp] the Google Translate test, written in raw Geb (no developers were hurt during the coding of this test (unless you equate drinking most of a bottle of wine to being “hurt” (which I do not (because I live in Wisconsin)))). Enjoy responsibly!

Download the working code from GitHub…

Note: this code, like the original Sahi and Selenium code, is “in the raw”, as it were. I.e. no page objects or custom methods to help readability/maintainability/*.ility.


22
Nov 13

Geb: Get Selected Text From A Select Dropdown

gebMy current client has decided to migrate their automated ui tests over to Geb, thus, I’ve been busily ramping up on it for the last couple weeks. Geb, written in Groovy, sits atop Selenium Webdriver and provides some great conveniences, including elegant css selectors and page object support. Additionally, using Spock as your test runner allows you to write your tests in a given/when/then dsl.

I’m finding Geb to be a great tool but like all tools, it has its quirks. Take getting the currently selected text from a select box… Geb does not currently (0.9.2) have an api for this. It has support for getting the currently selected value but you’ll have to do a little work to get the selected text. With a little trial and error (heavy on error), I was able to craft a reasonable solution to this problem in a page object selector. Here’s my example code…

Page Object Code (TestyPage.groovy):

Test Code (testy.groovy):

The trick here is in the page object. In the selector dropdownSelectedText, we use .find to get the first option tag, down the dom from dropdown, that has a value of dropdown.value() (in this case ‘ggg’) and then get the text from that option tag.

Reasonably clever…