Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"
-
Upload
trojmiejska-grupa-testerska -
Category
Software
-
view
81 -
download
2
Transcript of Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"
![Page 1: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/1.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/2.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/3.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/4.jpg)
4
Selenium WebDriver
Let’s automate simple web application!
![Page 5: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/5.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/6.jpg)
6
Selenium WebDriver
Demo
![Page 7: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/7.jpg)
7
Selenium WebDriver
What about more complex actions?
![Page 8: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/8.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/9.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/10.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/11.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/12.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/13.jpg)
13
AutoIT
Come to grips with MS Windows
![Page 14: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/14.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/15.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/16.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/17.jpg)
17
AutoIT
Step 2: Write the script in „SciTE” editor
![Page 18: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/18.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/19.jpg)
19
AutoIT
Demo
![Page 20: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/20.jpg)
20
Sikuli
Sky is the limit!
![Page 21: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/21.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/22.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/23.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/24.jpg)
24
Sikuli
Step 4: Write the script
![Page 25: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/25.jpg)
25
Sikuli
Demo
![Page 26: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/26.jpg)
26
Sikuli
Sikuli IDE
![Page 27: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/27.jpg)
27
Sikuli
Matching Preview
![Page 28: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/28.jpg)
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"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/29.jpg)
29
Sikuli
Sikuli IDE - demo
![Page 30: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/30.jpg)
30
![Page 31: Mateusz Radkiewicz - "Automate user's actions with Selenium, Auto it and Sikuli"](https://reader037.fdocuments.net/reader037/viewer/2022110122/55b3cf0cbb61eb5a3c8b47fc/html5/thumbnails/31.jpg)
31