Presentation is loading. Please wait.

Presentation is loading. Please wait.

GUI TESTING 2015-01-30, NOVATEC // LE. WHY TEST THE GUI?

Similar presentations


Presentation on theme: "GUI TESTING 2015-01-30, NOVATEC // LE. WHY TEST THE GUI?"— Presentation transcript:

1 GUI TESTING , NOVATEC // LE

2 WHY TEST THE GUI?

3 Why test the GUI? Web-UI Testing mit testIT - WebTester3 User Interface API Business Persistence Unit-Tests Component-Tests Integration-Tests System-Test

4 Why test the GUI? Web-UI Testing mit testIT - WebTester4 The User Interface … … is part of the application. … is an entry point into the system. … is what the customer perceives as THE „application“. … contains it‘s own business logic.

5 DIFFERENT KINDS OF GUI-TESTS

6 Agile Testing Pyramid Web-UI Testing mit testIT - WebTester6 Technology Business Detail Complexity / Cost Unit Tests Quantity Manual, Exploratory Testing Automated UI-Tests Service Layer Tests (API-Layer) Unit & Component Tests

7 GUI-Testing Pyramid Web-UI Testing mit testIT - WebTester7 Unit Tests UI System Tests UI Integration Tests UI “Unit” Tests

8 Different Kinds of GUI-Tests Web-UI Testing mit testIT - WebTester8 UI Mock-API UI „Unit“ UI Integration API Business Persistence UI System

9 PAGE OBJECT PATTERN

10 Scenario: Login Web-UI Testing mit testIT - WebTester10 Hello testuser! testuser ******** LOGIN Username: Password: login.html main.html

11 Scenario: Login with default Selenium code (and no optimization) Web-UI Testing mit testIT - public void testValidLogin () { webDriver.findElement(By.id("username")).sendKeys("testuser"); webDriver.findElement(By.id("password")).sendKeys("123456"); webDriver.findElement(By.id("login")).click(); String headline = webDriver.findElement(By.id("headline")).getText(); assertThat(headline, is("Hello testuser!")); public void testInvalidLogin () { webDriver.findElement(By.id("username")).sendKeys(„foo"); webDriver.findElement(By.id("password")).sendKeys("123456"); webDriver.findElement(By.id("login")).click(); String errorMessage = webDriver.findElement (By.id("errorMessage")).getText(); assertThat(errorMessage, is("Wrong Credentials!")); }

12 Scenario: Login Web-UI Testing mit testIT - WebTester12 Hello testuser! testuser ******** LOGIN Username: Password: login.html main.html LoginPage.java MainPage.java

13 Scenario: Login with Page Objects Web-UI Testing mit testIT - public void testValidLogin () { MainPage mainPage = loginPage.login("testuser", "123456"); assertThat(mainPage.getWelcomeMessage(), is("Hello testuser!")); public void testInvalidLogin () { loginPage = loginPage.loginExpectingError("foo", "123456"); assertThat(loginPage.getErrorMessage(), is("Wrong Credentials!")); }

14 Different kinds of Page Object methods Web-UI Testing mit testIT - WebTester14 Hello testuser! testuser ******** LOGIN Username: Password: Actions Information Getter Navigations Workflows

15 Page Object Pattern: Actions Web-UI Testing mit testIT - WebTester15 public LoginPage setUsername(String value){ username.sendKeys(value); return this; } public LoginPage setPassword(String value){ password.sendKeys(value); return this; }

16 Page Object Pattern: Navigations Web-UI Testing mit testIT - WebTester16 public MainPage clickLogin(){ login.click(); return createPageObject(MainPage.class); } public LoginPage clickLoginExpectingError(){ login.click(); return createPageObject(LoginPage.class); }

17 Page Object Pattern: Workflows Web-UI Testing mit testIT - WebTester17 public MainPage login(String username, String password){ return setUsername(username).setPassword(password).clickLogin(); } public LoginPage loginExpectingError(String username, String password){ return setUsername(username).setPassword(password).clickLoginExpectingError(); }

18 Page Object Pattern: Information Getter Web-UI Testing mit testIT - WebTester18 public String getErrorMessage () { return errorMessage.getText(); } public List getErrorMessages () { List returnValue = new LinkedList<>(); for(ErrorMessage message : errorMessages){ returnValue.add(message.getText()); } return returnValue; }

19 Page Object Pattern Web-UI Testing mit testIT - WebTester19 With the help of the Page Object Pattern… … GUI-Tests are maintainable. … new tests can be implemented with ease and speed. … tests focus on the “WHAT” not on the “HOW”.

20 WEB-TESTER

21 What is testIT WebTester? Web-UI Testing mit testIT - WebTester21 Best Practices from ears of actual project experience Page Object Pattern as a framework Efficiency-oriented Extendable in order to adapt to different functional and technological project contexts

22 WebTester What is testIT WebTester? Web-UI Testing mit testIT - WebTester22 Selenium Browser Testcode

23 WebTester Feature: Typesave API (Functional Classes) Web-UI Testing mit testIT - WebTester23

24 WebTester Feature: Event System Web-UI Testing mit testIT - WebTester24 EventRegistry click() EventListener

25 WebTester Feature: Extendibility Web-UI Testing mit testIT - WebTester25 You can … … call the Selenium API directly if any feature is missing. … create custom Page Objects for project specific components and widgets. … create custom Event Listeners, f.e. to handle exceptions. … create custom Browser Factories in order to customize the Web Driver to project specifications.

26 THE END , NOVATEC // LE


Download ppt "GUI TESTING 2015-01-30, NOVATEC // LE. WHY TEST THE GUI?"

Similar presentations


Ads by Google