Archive for January, 2015

Like Every Michelin Commercial Ever

Tuesday, January 27th, 2015 by The Director

Job posting:

A developer's job in an auto garage?

Can improved automobile tyres really make the world a better place? Should we trust developers the one to change the tyres?

To be honest, probably better than me: the last time I changed a tire, I cross-threaded two of the lug nuts and then snapped one of them off (with only a lug wrench, sir; I was motivated to remove that bolt). BECAUSE I BREAK THINGS.

QA Music: An Old New Song

Monday, January 26th, 2015 by The Director

Howard Jones “New Song”. Which is thirty-one years old, but never mind that.

Full disclosure: The mime in chains following the rock star around inspired me to get into QA.

Your Web Site’s Undergarments Are Showing

Thursday, January 22nd, 2015 by The Director

Keep in mind your invisible meta tags display when a user shares the link in various social media forms:

I see London, I see France, I see your Web site's wrongminded meta data

In this case, I think we can agree it’s a QA fail.

Waiting for One of Two Things To Appear on a Page in Java Selenium

Tuesday, January 20th, 2015 by The Director

I’ve been working on a Java Selenium test automation project, teaching myself Java and Selenium WebDriver along the way.

I ran into a problem that I didn’t see solved on the Internet elsewhere, but my skill at searching StackOverflow is not that good.

The problem is conducting an operation that might yield one of two results, such as success or an error message. Say you’ve got an registration form or something that can succeed if you put the right data in it or will fail if you put the wrong data in it. If the user successfully registers, a welcome page displays. If the user fails, an error message displays. And, given this is the Web, it might take some time for one or the other to display. And the implicit waits didn’t look like they’d handle branching logic.

So here’s what I did:

public int waitForOne(WebDriver driver, Logger log,
                      String lookFor1, String lookFor2){
  WebDriverWait wait = new WebDriverWait(driver, 1);
   for (Integer iterator = 1; iterator < 60; iterator++){
         WebElement element = 
         return 1;
        }catch (Exception e){
      }  // try 1
          WebElement element = 
          return 2;
         }catch (Exception e){
      } //try 2
  } //for loop
}// waitForOne

You could even create a longer list of events to wait for one of them to occur by passing in an array of strings and then using a For-Each loop to run through the list.

This sample looks for a Web element by its ID, but you could change it to use another By parameter, such as CSS Selector (cssSelector). Or, if you're feeling dangerous, you could pass in the By parameter as a string and parse it in the method to determine whether to use ID, CSS Selector, or a mix therein. But that's outside the simplicity of this example.

Also note that the For loop that limits the waiting for a total of sixty iterations, which in this case will max out at 120 seconds (at 1 second per attempt for 2 items a maximum of 60 times). You could pass the max in as a parameter when calling this method if you want. That's especially important if you're using a list of possible elements to look for. If you're passing in five elements, suddenly you're at a maximum time of five minutes if it times out completely. You might not want your tests to wait that long, especially if you're using the check multiple times per test.

I'm sure there are more elegant solutions for this. Let's hear them. Because, frankly, I'm not very good at searching StackOverflow, and I'd prefer if you'd just correct my foolishness here in the comments.

QA Music: I Am Machine

Monday, January 19th, 2015 by The Director

It’s been a while since we’ve had some Three Days’ Grace, so here is “I Am Machine”:

It’s been a while since we’ve had anything, actually. Perhaps I should post something.

wordpress visitors