Automated Tester

.science

This content shows Simple View

Selenium

SeConf 2016 Wrap Up

Selenium Conf 2016 closed up last week – this a very short post with my thoughts on it and my main take-aways. It is the first time I have attended the event and all in all I found it very interesting and extremely worth while.

Plus points

Meeting the Core Committers of the Selenium project

Not all of them, but I found myself bumping into the likes of Simon Stewart and Jim Evans and saying hello whilst wandering around the break room area. It is nice to meet people I have learned a lot from via the internet/ blogs/ stack overflow. There was also a large Q&A session toward the end featuring most of them. Not to mention other people that I have conversed with online in some way.

People experiencing the same pain

Lots of talks on scalability, parallel, test flake, cross browser testing and metrics. These reaffirmed that myself and my team are on the right tack (at the very least) and implanted some helpful ideas for the future.

Ideas and Innovation

There are some sweet toolsets and frameworks out there which I was not previously aware of, so my to do list got a bit longer as I earmarked several things to look into. More on these later if they materialise.

I did however feel like pretty much the only .Net guy there though, everyone else seemed to be using Java or Ruby. I also didn’t attend any of the workshops at Selenium Conf but maybe some other time.

In summary, if you get the opportunity to attend Selenium Conf in future then do so.



Measuring Speed and Performance with Sitespeed.io

I recently came across a fantastic open source speed and performance tool called Sitespeed and was pretty amazed by both what it can do and how it presents the results to you.

It has its foundations in some other cool stuff you may have heard of like YSlow, PhantomJS and Bootstrap and makes good use of WebPageTest too. It seems to support pretty much every platform too, I’m a .Net/ windows guy so I’ll be working with that. Lets have a look:

Install

Install via node – if you don’t have NodeJs get it here.

$ npm install -g sitespeed.io

Configure and Run

So to get some metrics out of something, lets run a simple test. Open a command prompt and run the following:

sitespeed.io.cmd -u http://www.google.co.uk -d 0 -b chrome -v –viewPort 1920×1080 –name Google_Report

If you’re a windows user like me don’t forget the .cmd on the end of the sitespeed.io initialiser, it’s an easy mistake to make! Let Sitespeed.io do it’s thing, in this particular instance we are crawling google to a depth of 0 (so just it’s landing page, for brevity.) and doing this with chrome, viewport size is set to 1920×1080, -v for verbose stdout, name gives it a name.

Running sitespeed.io

Hey presto, a performance dashboard:

Sitespeed.io report

Full example report is here.

We’re not really measuring against anything here just getting something pretty to look at, sitespeed.io recommends we create a Performance Budget to measure against which sounds like good advice to me, if you don’t know much about it they even recommend a some great articles to broaden your mind and follow best practice, to quote their site:

“Have you heard of a performance budget? If not, please read the excellent posts by Tim Kadlec Setting a performance budget and Fast enough. Also read Daniel Malls How to make a performance budget. After that, continue setup sitespeed.io :)”

Add this into your parameters and your report will illustrate what is falling in and out of your budget. So what else can we do with sitespeed.io?

  • Add a list of URLs to test against
  • Add authentication if you need to login somewhere (–requestHeaders cookie.json for example)
  • Drill down and get HAR files, maybe even convert to jmx for stress testing
  • Get screenshots
  • Get results in different formats (HTML/ XML and such)
  • Do multiple passes for comparison
  • Compare multiple sites
  • Throttle connections
  • Supports Selenium for running with different browsers
  • Supports Google Page Speed Insights
  • Supports Docker

In fact, there is way too much to list out here – luckily sitespeed.io has some very good documentation on how to configure so it should be easy to fine tune it to your needs. Furthermore if you use some other cool stuff like Graphite you can output the results to there.

Summary

The benefits of this should be clear, we can hook up a command in a build step on a CI server to either output some funky looking graphite metrics or generate performance dashboards regularly to catch performance issues before they get released.

I don’t yet know if this tool can be incorporated into existing automation tests with Selenium… or really if you would even want to do that, I had been looking into using Jan Odvarko’s HAR Export Trigger to compare against YSlow scores but sitespeed.io seems to kill lots of birds with one stone.

My first impressions are that sitespeed.io is a very powerful, easy to configure, cross platform performance tool that displays data in such as way that is easy to understand.

Bootnote

Keep your eyes peeled for sitespeed.io 4.0 which will have even more cool stuff going on, due to be released in a few weeks time.



SeConf 2016 – London

If you aren’t aware of the Selenium Conference in London in November, head on over to their website and book yourself a ticket. Early bird prices are still available so get them whilst they are cheap and I’ll see you there! Looking forward to sharing ideas and experiences with other testing pros out there.

Tickets are here.

Check out the website for all the details on speakers and workshops for the 3 day event.



Setting up Marionette/ GeckoDriver

 

Firefox will crash if you are using the Webdriver implementation for FirefoxDriver with Firefox v47 and beyond. This needs to be replaced with Mozilla’s GeckoDriver/ Marionette. At the time of writing it is still in a pre-release stage; meaning you may get unpredictable results against the current stable version of Firefox. You may want to use it with Firefox Nightly or Firefox Developer.

Below are some steps to get you going with Marionette/ Geckodriver C# .Net:

  • Download the latest release here
  • Extract the *.exe middleware and rename it to ‘wires.exe’
  • Place ‘wires.exe’ in to the given source code location
  • Include ‘wires.exe’ into your Solution and set properties to ‘Copy if Newer’

To set the Driver up in code, I have found the following works well in C# .Net:

            FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
            service.FirefoxBinaryPath = @"C:\Path\to\your\FF\exe.exe";
            FirefoxOptions options = new FirefoxOptions();
            options.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true);
            TimeSpan t = TimeSpan.FromSeconds(10);

            Driver = new FirefoxDriver(service, options, t);

Note that you need to put in the path to your Firefox *.exe or add it to your system Path variable.

If you are experiencing issues I would recommend having a look at the project bug list or the project GitHub issues page before raising any issues. There is also much more information over at the Mozilla page for Marionette.



Interacting with Dropdown lists with Selenium in C#

This article briefly explains how to, or at lease how I interact with dropdown menus in C#. Generally speaking I try to pass through the identifier and the value to select to a helper method which carries out the task.

Lets have a look at a typical step definition, first we’re waiting for the element to appear on screen and then selecting the option by value.

[When(@"I select the organisation (.*)'")]
public void WhenISelectTheOrganisation(string orgName)
{
Page.WaitForElementByClass(ClassName.Organisation);
Page.SelectFromDropDownByClass(ClassName.Organisation, orgName);
}

So lets look at SelectFromDropDownByClass:

public void SelectFromDropDownByClass(string dropDownClass, string dropdownValue)
{
new SelectElement(Context.Driver.FindElement(By.ClassName(dropDownClass))).SelectByText(dropdownValue);
}

We’re creating a new instance of Webdrivers’ SelectElement and passing through the class name and text of the item in the dropdown, keeping the identifier variable ensures we can reuse the same method elsewhere in the solution, you can interact and select items in other ways from dropdowns and also use other identifiers as necessary such as Id, CssSeleector and XPath.




top