‹ Takaisin Blogit-pääsivulle

Summary of the Summer RPA challenge results

· Materiaalit

Knowit organized a #mimmitkoodaa RPA challenge during the summer. The challenge was to create a robot to shop for groceries in an online webshop. The results were revealed in a webinar held on August 26th, where Knowit’s automation ladies Anu Lindell and Minna Mari Leivo presented two different code examples. People attending the webinar were also given the opportunity to ask about their own implementations

Code examples

Code will look different depending on the creator, and especially in the beginning, it can be very simple. The look and structure (architecture) of the code will evolve when the coder gets more experience. Often, they learn from other Robot Framework users. Minna Mari’s example shows what the code could look like at its most simple form, whilst Anu’s code has some advanced features. Especially at the beginning, it is important to focus on getting the code to work. Once you get a hold of the logic, you can improve the code. Like in all coding, there is no right or wrong way to code.

Example code / Minna Mari

Minna Mari’s functionalities are inside the test cases
Minna Mari’s code has xpaths that are copied from the browser

Code Example / Anu

Anu’s code uses variables
Anu’s code contains custom Keywords

Covered things and questions

Even the Xpath copied from browser’s developer tools is not always working, why?

Check the xpath you copied/wrote in the browser’s developer tools view. Press CTRL+F and write your xpath in the field. This way you can easily check if the xpath works, and if the element can be found with it.

Check log.html file for the captured screenshot, and make sure the robot is in the page you want it to be. Robot is considerably faster than the browser, so often you need to use Sleep or Wait Untill Page Contains Element keywords.

The difference between copied and written xpaths?

The xpath copied from browser’s developer tools is often absolute path to some element, for example /ul/li/div/a/div[3]/div, which break the xpath very easily, if there are any changes to the page’s structure. Those changes can also cause the xpath to find some completely different element.

We recommend learning how to write xpaths, for example //*[contains(text(),”text”)], so the structural changes on the page won’t cause trouble. Still, this method is not 100% sure either, because there can always be changes, which you need to update to your code.

Anu has resolved this situation by creating her own notepad, where she has written down the most important xpath syntaxes. From there it’s easy to edit them to fit the current need. All kinds of notes and helpful tools are completely accepted, because you don’t need to learn everything by heart. The most important thing to learn is to know where to look for more information.

Using different kinds of identifiers

It is completely ok to use different kinds of identifiers in one code. Identifiers include for example xpaths, css identifiers and id identifiers. Css identifiers are element modifying identifiers, for example class=content or class=modal-title. Id identifiers are names given to elements, for example id=receipelist or name=receipelist. 

Adding product to cart was difficult, what to do?

Code example 1 uses keyword Mouse Over, that hovers the cursor on an element, just as a user would do. After this the add to cart element comes visible and can be clicked. In example 2 the product page is opened and added to the cart from there.

Do you use robots outside of work? If yes, for what kinds of things?

Anu got familiar with the new browser library (called Browser) this summer. The library is still in progress. She has also tried to make a bot for her friend. The bot would follow the prices of rental apartments, but progress of that came to a halt because the announcements for rental apartments come in all kinds of formats.

Minna Mari has a webshop robot, that checks several webshops for new Fallout related merchandise.

Is automating browser applications easier than desktop applications?

It’s a good idea to check if a desktop application is actually browser based, which usually makes them as easy to automate as any browser page. Try pressing F12, it can open similar developer tool as in browser.

There is a library for automating desktop applications, called WhiteLibrary https://github.com/Omenia/robotframework-whitelibrary but neither Anu or Minna Mari has yet gotten the chance to try it out.

Using Batch files

You can write the robot startup code to a notepad file and save it with .cmd or .bat extension. Double clicking the icon, command prompt opens automatically, and the robot code is executed. Command prompt will close after the execution, so for results you need to check log.html or report.html file.

Ideas for the next practice for the #mimmitkoodaa community

  • Getting familiar with WhiteLibrary – for example automating Windows calculator.
  • GitHub usage together, so you don’t always need to start from scratch.
  • Robot to keep an eye on flight prices.
  • Robot to renew the ads on tori.fi

Let’s continue the discussion in the mimmitkoodaa Slack, in the #RPA channel! Milja will get you the invitation if needed. Other slack users can also add new users, so use your networks.  

Sources for learning more: 
https://testautomationu.applitools.com/robot-framework-tutorial/ (free) 

https://www.linkedin.com/learning/robot-framework-test-automation-level-1-selenium

Udemy has several courses. You don’t necessarily need to pay the full price, they have discounts fairly often!