testing desktop apps with selenium

22
Breaking down the barriers: Testing desktop apps with Selenium June 25, 2016

Upload: filip-braun

Post on 15-Apr-2017

397 views

Category:

Presentations & Public Speaking


1 download

TRANSCRIPT

Page 1: Testing desktop apps with selenium

Breaking down the barriers: Testing desktop apps with SeleniumJune 25, 2016

Page 2: Testing desktop apps with selenium

Speaker info

■ Filip Braun

[email protected]

■ https://cz.linkedin.com/in/filipbraun

■ Michal Vanek

[email protected]

■ https://cz.linkedin.com/in/michalvanek

Page 3: Testing desktop apps with selenium

Agenda1 Intro

2 Avast for Windows - UI testing challenges

3 Selenium and desktop apps

4 Demo

5 Everyday testing

Page 4: Testing desktop apps with selenium

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

Page 5: Testing desktop apps with selenium

How to test Avast UI?

Page 6: Testing desktop apps with selenium

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>

...

Page 7: Testing desktop apps with selenium

Avast architecture and testing possibilities■ Antivirus engine

− C++, assembler▪ integration/component▪ e2e tests in python ▪ using boost framework

− No UI testing needed

Page 8: Testing desktop apps with selenium

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 :(

Page 9: Testing desktop apps with selenium

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

Page 10: Testing desktop apps with selenium

10 - Selenium

Page 11: Testing desktop apps with selenium

Selenium for testing desktop apps?

11 - Let’s do it!

Sure, why not.

Page 12: Testing desktop apps with selenium

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

Page 13: Testing desktop apps with selenium

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

Page 14: Testing desktop apps with selenium

Opening debug console

■ Select some available port

■ Run the application with debug console enabled on that port

14 - Debug console

DEMO

Page 15: Testing desktop apps with selenium

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

Page 16: Testing desktop apps with selenium

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

Page 17: Testing desktop apps with selenium

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

Page 18: Testing desktop apps with selenium

DEMO

18 - Demo

Page 19: Testing desktop apps with selenium

How we run the test?

■ 3 levels of tests

− short

− medium

− long

▪ UI tests using selenium

- daily and often

Page 20: Testing desktop apps with selenium

Infrastructure for running automation tests

■ Jenkins

− test executor

■ Linux server farm

− using DBV

■ VirtualBox

− many Windows OSes

Page 21: Testing desktop apps with selenium

21 - Q&A

Page 22: Testing desktop apps with selenium

Contact us later

■ Filip Braun

[email protected]

■ https://cz.linkedin.com/in/filipbraun

■ Michal Vanek

[email protected]

■ https://cz.linkedin.com/in/michalvanek

22 - Contact us