31
1 Automate user’s actions with Selenium, AutoIT and Sikuli Mateusz Radkiewicz

Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

Embed Size (px)

Citation preview

Page 1: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

1

Automate user’s actions with Selenium, AutoIT and Sikuli

Mateusz Radkiewicz

Page 2: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

2

Let’s automate simple web application!

• Selenium WebDriver

What about more complex actions?

• Selenium Actions, Javascript Executor

Need to interact with OS interface?

• Java.awt.Robot

Come to grips with MS Windows.

• AutoIT

Sky is the limit!

• Sikuli

Agenda

Page 3: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

3

Selenium WebDriver

Basic Selenium WebDriver interactions:

• Open a web page

• Hit „back” and „forward” buttons

• Refresh a page

• Get current URL

• Delete or add a cookie

• Get the source of a page

• Switch to another tab/window

• Close the tab

• Click a link, button, checkbox, radiobutton, image

• Enter text into textfield, textarea

• Get text from a label

• Get web page element’s attributes

• Check if element is displayed

• Get element’s location on the screen

Control a browser Interact with a page

Page 4: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

4

Selenium WebDriver

Let’s automate simple web application!

Page 5: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

5

Selenium WebDriver

Amazon.com – simple test case

Objectives:

• Go to amazon.com

• Search for „octocopter”

• Get number of search results

Page 6: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

6

Selenium WebDriver

Demo

Page 7: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

7

Selenium WebDriver

What about more complex actions?

Page 8: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

8

Selenium WebDriver

Selenium Actions

Simulate more advanced actions using mouse and keyboard:

• Click right mouse button

• Double click

• Move mouse over element

• Drag and drop

• Press combination of keys

• Hold Ctrl key and click elements on the list

Page 9: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

9

Selenium WebDriver

Selenium Actions - example

Objectives:

• Select „Ford” and „Porsche”

• Move them to the right container

Page 10: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

10

Resize text area by modifying „rows” attribute

Scroll the page left by 20 pixels

Enter text with JavaScript

Enable the button

Selenium WebDriver

Javascript Executor – a little bit of magicA simple way to execute JavaScript code directly from Selenium test

Page 11: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

11

Java.awt.Robot

Need to interact with OS interface?Robot lets you press the keys and click on the coordinates on a screen.

Page 12: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

12

Java.awt.Robot

Robot - exampleObjectives:

• Open TED.com page

• Press Ctrl+F to enable search

• Search for „gems” word

Page 13: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

13

AutoIT

Come to grips with MS Windows

Page 14: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

14

AutoIT

Features• Simple scripting language for automating Windows GUI

• Interacts with all standard windows controls

• Simulates keyboard and mouse actions

• Suitable for general scripting and creating simple applications

• Scripts can be compiled into standalone *.exe

• Easy to learn

• Freeware

Page 15: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

15

AutoIT

File upload with Selenium and AutoIT - exampleObjectives:

• Go to „https://careers.kainos.com/members/”

• Click „Upload a CV …” button

• Enter a path to local file and click „Open”

Page 16: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

16

AutoIT

Step 1: Inspect the windowUse „AutoIT Window Info” tool to identify the window, field and button.

Page 17: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

17

AutoIT

Step 2: Write the script in „SciTE” editor

Page 18: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

18

AutoIT

Step 3: Compile the code

Step 4: Include AutoIT *.exe into Selenium test

• Open „SciTE” menu Tools > Compile

• Enter location of output *.exe file

• Click „Compile Script”

Page 19: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

19

AutoIT

Demo

Page 20: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

20

Sikuli

Sky is the limit!

Page 21: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

21

Sikuli

Features• Lets you automate anything that is displayed on the screen

• Uses image recognition algorithms to identify GUI components

• Can reach anything that’s out of range for other tools

• No need to have access to application’s structure

• Cross-platform

• Freeware

• Provides own IDE (Jython)

• Provides libraries for development in Java

• Extremely easy to create automatic test, problematic to maintain it

Page 22: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

22

Sikuli

File download with Selenium and Sikuli - exampleObjectives:

• Go to „https://code.google.com/p/altdrag”

• Click „Download installer”

• Click „Save File” button

• Click „Save” button in the next window

• Press Win+D to minimize all windows

• Verify downloaded on the desktop

• Delete above file

Page 23: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

23

Sikuli

Step 1: Download and install Sikuli• http://www.sikuli.org

Step 2: Include Sikuli in your project• Add „sikuli-java.jar” library in your IDE

Step 3: Create screenshots

Page 24: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

24

Sikuli

Step 4: Write the script

Page 25: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

25

Sikuli

Demo

Page 26: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

26

Sikuli

Sikuli IDE

Page 27: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

27

Sikuli

Matching Preview

Page 28: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

28

Sikuli

Let’s rock!Objectives:

• Run the script on Windows

• Switch to Ubuntu on VMware

• Open Firefox

• Navigate to Rio de Janeiroon Google Maps

• Collapse side panel

• Enable Google Street Viewon Astoria Palace

• Look around Copacapanauntil you find a girl on a bicycle

• Zoom into the girl

Page 29: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

29

Sikuli

Sikuli IDE - demo

Page 30: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

30

Page 31: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"

31