Skip to main content

Let the machine check it, I get bored easily

In the spirit of my new blog I thought I would start with a trick I learn't the other day. I really don't like repetitive testing and I think its our duty (strong words I know) to find interesting ways to get over these challenges.

So I was charged with a piece of API testing. It was a simple sign up process, which set the user into a particular status. The status wasn't returned by the API response  (just a success or failure) however so I needed to go off to the front end to check it.

I had been toying with using SoapUI and Selenium together for some time so I thought what the hell and attempted to hack the two together in a relatively graceful fashion (as we do as testers sometimes). I came up with this approach:
  1. Download the latest Selenium Standalone server.
  2. Put it in here - SoapUIRoot\Bin\Ext
  3. Fire up Soap UI, add a Suite>Test>Groovy Step
  4. Learn Selenium Webdriver (you'll need to one day, may as well get on with it)
In terms of Webdriver I kept it really simple:

import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import org.openqa.selenium.ie.InternetExplorerDriver
import org.openqa.selenium.support.ui.ExpectedCondition
import org.openqa.selenium.support.ui.WebDriverWait
  
        // Create a new instance of the Internet Explorer driver
        // Notice that the remainder of the code relies on the interface,
        // not the implementation.
        WebDriver driver = new InternetExplorerDriver()

        // And now use this to visit the site
        driver.get("https://mysite.project.qa.com/login")

        //Get past the Certificate Problem
        WebElement override = driver.findElement(By.id("overridelink"));
                   override.click();

         //Enter Username and Password, Login
         WebElement username = driver.findElement(By.id("username"));username.sendKeys("User");
         WebElement password = driver.findElement(By.id("password"));password.sendKeys("Password1");
         WebElement signin = driver.findElement(By.id("submit"));signin.click();
                  
         //Find the Customer with the number
         WebElement custno =    driver.findElement(By.id("CustomerID"));custno.sendKeys(${#TestCase#CustID});
         
        //Assert the Status
        assertTrue(isElementPresent(By.linkText("Status is Live")));
         
         //Close the browser
         driver.quit();
 I came out with a test that looked like this:
  1. Groovy step to generate a random username and GUID
  2. Property transfer to get them into a HTTP step
  3. HTTP Post to the API (and capture the Customer ID)
  4. Transfer step for Customer ID
  5. Groovy step to run Selenium and use the Customer ID to find the sign up and check the status
And there we are! One very boring bit of testing automated forever. Testing and analysis of new stuff is fun, checking old stuff is a bit dull. Automate now to enjoy the future more.



Comments

Popular posts from this blog

A Lone Tester at a DevOps Conference

I recently had the chance to go to Velocity Conf in Amsterdam, which one might describe as a DevOps conference. I love going to conferences of all types, restricting the self to discipline specific events is counter intuitive to me, as each discipline involved in building and supporting something isn't isolated. Even if some organisations try and keep it that way, reality barges its way in. Gotta speak to each other some day.

So, I was in an awesome city, anticipating an enlightening few days. Velocity is big. I sometimes forget how big business some conferences are, most testing events I attend are usually in the hundreds of attendees. With big conferences comes the trappings of big business. For my part, I swapped product and testability ideas with Datadog, Pager Duty and others for swag. My going rate for consultancy appears to be tshirts, stickers and hats.

So, lets get to it:

3 Takeaways

Inclusiveness - there was a huge focus on effective teams, organisational dynamics and splitt…

Wheel of Testing Part 2 - Content

Thank you Reddit, while attempting to find pictures of the earths core, you surpass yourself.
Turns out Steve Buscemi is the centre of the world.

Anyway. Lets start with something I hold to be true. My testing career is mine to shape, it has many influences but only one driver. No one will do it for me. Organisations that offer a career (or even a vocation) are offering something that is not theirs to give. Too much of their own needs get in the way, plus morphing into a badass question-asker, assumption-challenger, claim-demolisher and illusion-breaker is a bit terrifying for most organisations. Therefore, I hope the wheel is a tool for possibilities not definitive answers, otherwise it would just be another tool trying to provide a path which is yours to define.


In part one, I discussed why I had thought about the wheel of testing in terms of my own motivations for creating it, plus applying the reasoning of a career in testing to it. As in, coming up with a sensible reflection of real…

The Team Test for Testability

You know what I see quite a lot. Really long-winded test maturity models. 

You know what I love to see? Really fast, meaningful ways to build a picture of your teams current state and provoke a conversation about improvement. The excellent test improvement card game by Huib Schoots and Joep Schuurkes is a great example. I also really like 'The Joel Test' by Joel Spolsky, a number of questions you can answer yes or no to to gain insight into their effectiveness as a software development team.

I thought something like this for testability might an interesting experiment, so here goes:

If you ask the team to change their codebase do they react positively?Does each member of the team have access to the system source control?Does the team know which parts of the codebase are subject to the most change?Does the team collaborate regularly with teams that maintain their dependencies?Does the team have regular contact with the users of the system?Can you set your system into a given state…