SeleniumConf Tokyo 2019

Introduction to SeleniumConf

Selenium is one of the most popular automated software testing frameworks for the past decade. There are Selenium conferences in different cities around the world held on a regular basis. This year’s event, for the first time, was held in Tokyo. And it was also our first time attending a technical conference in Japan. We found the atmosphere was totally different from conferences in the US and Europe.

The location of the event was the Tower Hall Funabori, located in a residential area in Tokyo that is a far cry from busy areas like Shinjuku or Shibuya. It was a sunny and perfect day for a conference.

LINE was one of the sponsors for this year’s conference. We set up a booth to introduce what it’s like to work at LINE. The booth was quite popular because we had LINE sticker giveaways, which quickly ran out on the first day. 

The conference was composed of workshops, keynotes, and 2 tracks of sessions including lightning talks. It was a conference packed with software engineers in testing and test engineers from all over the world. The following sections are some of the highlights of SeleniumConf Tokyo that left a strong impression. 

Workshop

This workshop titled “Fix a Bug, Become a Committer” was hosted by Simon Stewart, the inventor of WebDriver and the current person in charge of the Selenium project. He began by introducing the overall architecture of Selenium’s open source code and how to selectively build the code. He made sure we were able to run Selenium from our local machines. This took us the entire morning and more than 900 MB of hard disk space. In the afternoon, he showed us how he fixes bugs, writes code, and debugs. There was a case when he underestimated the size of a bug, hence eventually reverting his partial fix but the beauty of it was that we were able to observe how he thinks while writing code since he was thinking out loud. He hoped that we could find bugs in the code and have us actively fix a few of them, but we didn’t have enough time.

Selenium consists of an IDE, client API, and WebDriver. It’s a large open source project maintained by a small team. If anyone is able to contribute a fairly large amount of code, they can become a contributor to this project. He encouraged everyone to contribute to the Selenium repository and join their Slack group discussion if there were any pending pull requests or questions.

Keynotes

State of the Union

After the workshop, Simon Stewart took the stage again to deliver Selenium’s State of the Union. He started by metaphorically describing Selenium as a series of snowballs. He emphasized that “each snowball is unique but can work together to become a snowman.”

  • Selenium WebDriver – APIs used to write your tests
  • Selenium Grid – Mechanism to run tests in parallel
  • Selenium IDE – Record and playback tool to run tests
  • Selenium Tests – Tests written by users

He mentioned Selenium running in Docker containers and also in the Cloud using Kubernetes recipes. More importantly, he announced the release of Selenium 4 Alpha version 1. While Alpha version 1 is not officially available on the Selenium website, you can still get it from the MVN repository. Highlights of the new version include the following.

  • New and better documentation
  • IDE playback with WebDriver
  • IDE as a native app and code export
  • Language bindings will use W3C protocol only
  • Grid with refreshed architecture
  • Chrome Debugging Protocol Support

Sessions

How I learned to stop worrying and love record and playback

The speaker of the session was Dave Haeffner, whom I’ve met before at STAREAST 2015 where he was hosting a whole-day tutorial for Selenium. Dave has promoted Selenium for years, even going so far as to building a service that sends you newsletters alongside a free Selenium tutorial. The topic of his session at SeleniumConf Tokyo was explaining why he is back to using Selenium IDE.

Many engineers have complained about the record and playback feature of the Selenium IDE. Recorded scripts were often not robust enough, prompting you to modify the scripts anyway to pass the tests. So why not just write the scripts yourself in the first place?

Despite this, Dave has emphasized that Selenium IDE is in a constant state of evolution. Dave talked about 10 nice features the tool should have going forward:

  • Smart element locators
    Small UI changes should not break tests. You should be able to record all possible locators, and auto-retry others if the primary locator fails to locate.
  • Conditional waiting
    Smart waiting should be built-in, opposed to the current fixed sleep time that delays test execution.
  • Control structures
    “For loop” should be possible for repeated steps, “if else” should be possible for different conditions.
  • Easy assertions
    Recording steps is easy, but adding your assertions is not that easy. This feature should provide you an easy way to insert your assertions.
  • Modifications without redo
    You should be able to easily modify steps without recording the entire process again.
  • Reusable steps
    If login is a required step for all scenarios, you should be able to extract the login step as a common function and then re-use it in other scenarios.
  • Cross-browser support
    The scripts recorded on one browser should be applicable on other major browsers.
  • Reporting
    Reports should have detailed logs and rich content like screenshots and video for troubleshooting. Test case statistics would also be useful. 
  • Ability to insert code
    There is always a chance you have to add code or modify recorded scripts. Having the ability to insert code would help with that.
  • Continuous integration
    The command line runner is important for continuous integration.

The surprise was that all of these great features are built into the latest version of Selenium IDE. Perhaps it’s time for you to try it out again!

The Future of Selenium – A Deep Dive into the W3C WebDriver Specification

Peter Thomas illustrated the history of Selenium and showed us a demo of the interesting aspects of Selenium during his talk.
   

Peter mentioned how WebDriver has been a W3C recommendation since 2018, which is a great achievement for the Selenium project. When it’s an industry standard, everyone can benefit from using it for developing and testing web services.

The most interesting part of the session was when Peter demonstrated controlling WebDriver with Postman. We mostly develop tests using the Selenium client library, like how we would use Python or Java libraries. The library in the middle takes care of all the details so that we can control WebDriver in a simpler way.
Even though Selenium and WebDriver are for UI testing, the real mechanism is the library that controls the browser with WebDriver API. I will illustrate the steps using cURL commands below.

Let’s say we are using Firefox as our browser, and we are searching Google using the keywords “Hello, World!”

1. First of all, we have to install Firefox and download geckodriver.

2. Run geckodriver. The local server is ready with port number 4444.

3. Create a session using the /session API  with minimal capability “browserName” = “firefox”.

curl -X POST \
  http://localhost:4444/session \
  -H 'Content-Type: application/json' \
  -d '{
    "browserName": "firefox"
}'

We get sessionId 4b8cbe19-57e7-7648-a302-5e1460d36a6f in the response, and one Firefox browser window is opened.

{"value":{"sessionId":"4b8cbe19-57e7-7648-a302-5e1460d36a6f","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"67.0.4","moz:accessibilityChecks":false,"moz:buildID":"20190619235627","moz:geckodriverVersion":"0.24.0","moz:headless":false,"moz:processID":5587,"moz:profile":"/var/folders/zd/5wdw9fr94x1ggqrm_9jd8xkw0000gp/T/rust_mozprofile.RoI4eUEsi9Mz","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"mac","platformVersion":"18.6.0","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}

4. Visit the URL using /session/{session id}/url API with “url” = “https://google.com”.

curl -X POST \
  http://localhost:4444/session/4b8cbe19-57e7-7648-a302-5e1460d36a6f/url \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://google.com"
}'

The browser visits https://google.com as expected.

5. Find the page element input box using the /session/{session id}/element API with locator “input[name=’q’]”

curl -X POST \
  http://localhost:4444/session/1e48e567-d9b7-304f-9cb1-57c640f0d8e1/element \
  -H 'Content-Type: application/json' \
  -d '{
    "using": "css selector",
    "value": "input[name='\''q'\'']"
}'

We get the element ID of the input box which is d2b56a1d-6df6-9a45-9d50-f9458f77ad7d.

{"value":{"element-6066-11e4-a52e-4f735466cecf":"d2b56a1d-6df6-9a45-9d50-f9458f77ad7d"}}

6. Fill in the keywords “Hello, World!” and add Return key “\uE006” to the input box using the /session/{session id}/element/{element id}/value API.

curl -X POST \
  http://localhost:4444/session/4b8cbe19-57e7-7648-a302-5e1460d36a6f/element/d2b56a1d-6df6-9a45-9d50-f9458f77ad7d/value \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "Hello, World!\uE006"
}'

The page shows the search result of “Hello, World!”

In the end, Peter showed us a demo of his open-source automation framework Karate. Using Karate, you can write automation scripts in plain text using the BDD syntax. UI tests and API tests can be mixed into one test case. Additionally, it supports most platforms like Chrome using WebDriver, Windows apps using WinAppDriver, and mobile devices using Appium.

ZOZO’s Automating testing of automatic measurement application

Zozosuit is a futuristic skintight bodysuit that captures the measurements and unique body shape of the wearer, allowing them to order custom-fit clothing. It was a good concept but definitely an expensive investment made by their founder as Zozosuits are delivered to users for free. Eventually it stopped selling in many countries except Japan. 

This session talked about the complications they had to go through in order to test Zozosuit’s application. In order to run a single test case, they needed a real person to be the guinea pig, a real tailor to check expected measurements, and then run the actual test which approximately took an hour. It was resource-intensive, so they wanted to run automated testing in order to save the time and resources it would normally take if tested manually.

Their solution was to use Selenium to control the screen which acted as the person being measured, use Apple Script and Python to trigger the application, and use a USB hub to run the tests in parallel. Ultimately, they were able to run 4 parallel tests in 10 minutes, which reduced the time significantly.

Collaborating on Open Source Software: How I Started contributing to Open Source and Why You Should Too

Almost all developers and testers have used open source software (OSS), but comparatively few have ever contributed to the OSS community. The speaker, Marit, shared her experience in contributing to the community hoping to inspire others to do so as well. There are actually many ways we can contribute to these projects; such as fixing bugs, adding features, refactoring, upgrading dependencies and so on. Even if you’re not a developer, there are also many ways to contribute; such as writing and fixing documentation, creating issues, testing, and so on. In addition, a community always keeps channels such as Slack or IRC open to communicate with each other online. Helping the community by answering some questions is also a great way to give back.

It’s a great feeling to have your first pull request (PR) approved and merged in an OSS project. And that is why Marit encourages everyone to send their first PR. 

Conclusions

It was the first time we’ve ever attended SeleniumConf, and it was great to meet the people behind the automation tools we used to use daily. Although, we have recently switched to using Cypress for API and E2E automation testing, both Cypress and Selenium communities have similar objectives and problems that we can all relate to. It was great that LINE was a sponsor to this conference and encouraged their employees to practice and promote test automation in their day-to-day work to the community. We have an awesome OSS community who are willing to lend a hand, and we have benefited a lot from their great work. We’re looking forward to contribute back in our own ways in the future.