What is QA?

This is something that is discussed a lot of Twitter, sometimes defended strongly and sometimes turned into humour. The situation still doesn't appear to be changing though. In my opinion its very straight forward, Quality Assurance (QA) is not Testing nor is it the stage or step that takes place during a project to determine the quality of a product. I believe the current use of such terms is damaging to both QA and Testing, one can exist without the other, in saying that though, if Testing was happening, then one could easy say that the companies approach to QA is to have a Testing stage. However an approach to QA could not have a Testing phase at all. QA, as mentioned is widely used throughout the software industry as the acronym for Quality Assurance, the stage in developing software were we assure the quality, where an individual or a team lead/manager stamps the product with a seal of quality.

“I QA Spokesperson, hereby state that the quality of the product has been assured, I have signed it so”.
That's some impressive work these individuals or teams take on, they must have spent weeks even months painfully trawling over all the available data, they must have done the following and more:
  • Gone back and interrogated the BA/PO’s, “You, is this what you really wanted, IS IT! You better not be lying to me, John! Bring in Sarah, she will make them talk! 
  • Cross references the written requirement to ensure they were indeed what the BA/PO stated they wanted. Ensuring they are all present and correct and of course stored in the correct format and in the correct location. Oh, how could I forget then made sure that they aligned with what they wanted the system to do. 
  • Reviewed every line of code, checked every DB table, debugged every build job to ensure its not doing and secret trickery. 
  • Ran each unit test manually, checked that there was enough unit tests. Counted them to double check that the CI server wasn't lying to them or the IDE. 
  • Interviewed all the developers, “Did you fully understand the feature you were writing?” Dev: “Yes I did”. “Oh yea, I bet you did, bet you wrote more code then need though didn't you, changed other functionality that wasn't necessary too I bet, you £$%£”. Dev: “I didn't, I swear”. 
  • Checked every single piece of existing functionality to ensure nothing has changed. 
  • Tested all the new functionality of the product following the release.
I could go on but you get my point and the train journey home is only 1 hour. But what's more important here is that all this has to take place in the stage that’s called QA, because none of the other stages have QA in their title, so obviously nothing can be done in those stages, right? QA is not a stage or a step and certainly isn't a team or someone's role. It’s not testing or checking. So what is QA? For me I use QA to label all the things individuals, teams and companies do to create an environment in which people can work to the best of their abilities and in turn produce quality products. In my view QA can take many forms, I would class the following as QA:
  • Employing talented people in the correct roles for them. 
  • Free tea and coffee, perhaps even biscuits and fruit. 
  • Two monitors, perhaps even three. 
  • A comfy chair. 
  • Having coding standards and reviews. 
  • Doing TDD or having unit tests. 
  • Some form of automated checking. 
  • Flexible working hours. 
  • Fair salaries. 
  • A test team. 
  • Regular team meetings, be it in the form of standups, retros even 1-2-1s. 
  • Continuous integration. 
  • Training and conferences.
All these things plus hundreds more I am sure you could all come up with, in my opinion come under QA. Allowing the employees to work to the best of their abilities in a comfortable friendly environment where they are encouraged to raise their concerns and have them heard. QA as I described it, can take care of itself, I've had the privilege of working at places where QA is in the culture but they didn't know it. There referred to it as testing, in this context a stage where testing and checking was done as QA, as soon as I made them aware of the difference, there was realisation that QA was throughout the whole process. This caused many to realise that some of things they did were in fact QA, subsequently this lead to them studying the impact of such tasks and improving them because of its relation to quality. I can’t help but see this post as a stepping stone because whilst QA is definitely not Testing, I am not sure what I have described is even QA. This requires more thought but I am not sure QA even needs to be a “thing” any more. What I have described as QA isn't assuring quality at all, its trying to embed quality into employees, processes and subsequently the product. So there is certainly work to be done to stop testing stages and test teams being referred to as QA, but for the future of QA?

“QA is Dead!” or atleast “QA is severely wounded”

Checking If An Element Is Present/Displayed With WebDriver

On several sites I have worked on in recent years there has always been a check scenario whereby I have wanted to check that something isn’t on the page, such as a error message or a field not required in a given context.

WebDriver by design, as its intended to show you what the user can see, will return a NoSuchElementException if given a locator for an element that shouldn’t be on the page.

So what most people write is a function containing a try catch and subsequently return a bool indicating if the element is on the page or not. Something like this:


In my opinion this is a nice way to do it, you could of course return the exception and assert against that, but I find bool a nicer approach. But what is often overlooked with this approach is the default timeout for the driver. If you haven’t altered this, then it will be 0 so you won't have this problem, but I know a lot of people do to reduce flakiness, so lets says its 20 seconds. What happens when you run the above code is WebDriver will try to find the element for that time duration, making it look like your test has hung, before it declares it not present. This can be a lengthy amount of time depending how many times you are looking for something not to be present during your suite.

One way to achieve this is to reduce the driver timeout before the try catch and then setting it back to the appropriate value afterwards. This could be done in a helper class or if you have created a custom driver can be added as a method on that. Something like this:


Another way to do this is with the IDisposable interface as introduce to me by a chap called James Barker, use the using command and then do your call inside there, then the timeout would be automatically set back after the call during the disposal. Something like this:


However if you are following the PageObject approach and using the PageFactory then you would want to be passing the appropriate IWebElement in to the method. You would initially think that this isn't possible because the element would be null, but it actually isn't because at the point of initialising the PageObject with the factory is creates it as an IWebElementProxy (something like this, some black magic :) ) so you can actually pass the IWebElement to a method and call the IsDisplayed() method inside a try catch like above.

I achieve this with the following code, but note that this code isn't full proof because if the element is present but not displayed you will get false, if the element isn't present you will get false. So if you intention is to check that the element isn't in the code at all, your probably better following a pattern above. Issue there will be you will likely have to duplicate your locator or you could do some nasty reflection to get the locator, or stick it in a const string. However I haven't had a need to do that and for me as long as a user cannot see the element, I am happy.


So there you have it, several approaches to dealing with checking if an element is present/displayed.
Hope this is of use to some of you and happy coding!

Update
Here is another approach for you. Jim Holmes asked me and Jim Evans how to check if an element is not present, Jim replied with this very neat approach, which could also be used to check if an element is present too. The reason this works is due to the fact that findElements won't throw an exception if non are present, the collection is just empty.