testing desktop apps with selenium
TRANSCRIPT
Breaking down the barriers: Testing desktop apps with SeleniumJune 25, 2016
Speaker info
■ Filip Braun
■ https://cz.linkedin.com/in/filipbraun
■ Michal Vanek
■ https://cz.linkedin.com/in/michalvanek
Agenda1 Intro
2 Avast for Windows - UI testing challenges
3 Selenium and desktop apps
4 Demo
5 Everyday testing
Avast Software, The Czech republic■ antivirus and security company■ products
▪ Antivirus▪ Mobile security▪ SecureLine▪ CleanUp▪ Passwords
■ platforms▪ Windows▪ Android▪ Mac/iOS
■ over 230 millions users■ www.avast.com
How to test Avast UI?
How to test Avast UI?settings_general.htm <!-- SPECIAL SCANS --><div #s_boxes_ctnr behavior_instance="AvBehav_SlidingBoxes"> <caption .sbox> <div ._left /><span IDS="6748">Special scans</span><div ._right/></caption>
<div .expandable style="behavior: AvBehav_SpecialScanList;"> <div .content> <table style="width:100%"> <tr .simple_box .ssaver image_id="ssaver"> <td><div IDS="8380">Screen saver scan</div></td> <td><div .flat_btn name="settings" av_command="settings(dialog=IDR_HTM_DIALOG_SETTINGS_SSAVER,scan_id={CB6AE6F8-D9A8-4794-B2BF-53A84058C58F})" IDS="6096">Settings</div></td> </tr>
...
Avast architecture and testing possibilities■ Antivirus engine
− C++, assembler▪ integration/component▪ e2e tests in python ▪ using boost framework
− No UI testing needed
Avast architecture and testing possibilities
■ Avast GUI frameworks▪ Avast UI page looks like a website
− Htmlayout▪ renderer of HTML layout content for old parts of UI▪ untestable by standard methods :(
▪ partial success with Sikuli
− CEF▪ new parts of UI▪ allows to use selenium webdriver for testing
We used to fail in UI automation testing :(
Motivation and idea outline■ GUI testing tools are often image based− Too clumsy− Very inflexible− One small change in GUI requires several changes in tests
9 - Motivation and idea outline
■ Tests require too much maintenance
■ Solution− Testing tool that can access the base structure of GUI− Allows framework creation
■ We have that in Web testing
10 - Selenium
Selenium for testing desktop apps?
11 - Let’s do it!
Sure, why not.
Where is the magic?
■ Connect Selenium to a desktop app
■ Access its GUI content as a website
■ Control it as a website
12 - Where is the magic?
■ Do all the Selenium magic
− Build a powerful framework
− Run tests in multiple environments
Some prerequisites■ CEF
− Chromium Embedded Framework
− Browser engine
− Provides browser capabilities to desktop application
13 - Prerequisites
■ DevTools for CEF
− Debug console tool for Google Chrome
■ Google Chrome
■ ChromeDriver
Opening debug console
■ Select some available port
■ Run the application with debug console enabled on that port
14 - Debug console
DEMO
Connecting Selenium driver to the app
■ Open a connection point
− Start CEF debug console on some port
15 - Connecting to app
■ Connect ChromeDriver to debug console
■ Access and control the application through the console
■ Let Selenium do its job
Connecting Selenium driver to the appfrom selenium import webdriverCEF_PORT = "55555"DEBUGGER_ADDRESS = "localhost:{}".format(CEF_PORT)CHROMEDRIVER_PATH = "c:\\selenium\\chromedriver.exe"class Driver(object): # Initialize driver instance @classmethod def initialize(cls): options = webdriver.ChromeOptions() options.debugger_address = DEBUGGER_ADDRESS cls.instance = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=options)
16 - Connecting to app
Connecting Selenium driver to the appfrom driver import Driverfrom selenium.webdriver.support.wait import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ecfrom selenium.webdriver.common.by import Byclass Hns(object): # Returns list of WebElements - all displayed devices @classmethod def get_devices(cls): WebDriverWait(Driver.instance, 5).until(ec.presence_of_element_located((By.ID, "hns__device-0"))) return Driver.instance.find_elements_by_xpath("//*[contains(@id, 'hns__device')]")
17 - Connecting to app
DEMO
18 - Demo
How we run the test?
■ 3 levels of tests
− short
− medium
− long
▪ UI tests using selenium
- daily and often
Infrastructure for running automation tests
■ Jenkins
− test executor
■ Linux server farm
− using DBV
■ VirtualBox
− many Windows OSes
21 - Q&A
Contact us later
■ Filip Braun
■ https://cz.linkedin.com/in/filipbraun
■ Michal Vanek
■ https://cz.linkedin.com/in/michalvanek
22 - Contact us