26
Heuristics to scale your framework Prasad Kalgutkar

Heuristics to scale your framework

  • Upload
    vodqa

  • View
    104

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Heuristics to scale your framework

Heuristics to scale your framework

Prasad Kalgutkar

Page 2: Heuristics to scale your framework

2

Page 3: Heuristics to scale your framework

What do I do?

3

Test Mobile Apps (iOS & Android)

Automate in Ruby with Calabash & WATIR

Write scenarios in Cucumber

Test a Mobile website too!

Client Consulting on the way!

Page 4: Heuristics to scale your framework

Role of Automation

4

On time delivery

Fast Feedbacks

Save time & efforts

Better test coverage

Sanity test builds Accuracy

Page 5: Heuristics to scale your framework

“ If you automate a mess, you just get an automated mess!

” - Rob Michael

5

Page 6: Heuristics to scale your framework

Common Challenges

6

➔ Test Data

➔ Add / Modify Libraries

➔ Extensibility

➔ Locators

➔ Debugging

➔ High Maintenance

Page 7: Heuristics to scale your framework

Let’s Solve it! #1

7

Page 8: Heuristics to scale your framework

Test Data Management

Keep it simple & understandable

Close to domain

Avoid Excel Sheets

Avoid Fetching from DB

Leverage the tech stack

8

Page 9: Heuristics to scale your framework

In the Scenario@Test

public void shouldTestLoginForInvalidUser(){

new LoginPage()

.enterUsername(“BadMan”)

.enterPassword(“Wrong”)

.submitLogin()

.checkErrorMessage(“Invalid Credentials”);

}

9

Given I login as “Invalid” with password “Wrong”Then I see an error message as “Invalid Credentials”

<= JUnit

BDD =>

Page 10: Heuristics to scale your framework

Test HashesWhen I enter “VISA” card details

10

def testCards{

:VISA => {

:NUMBER” => “4000100040001000”

:EXPIRY => “2018”

},

:AMEX => {

:NUMBER => “4111311141113111”

:EXPIRY => “2020”

}

}

Page 11: Heuristics to scale your framework

Test Data ObjectsWhen I use “gold_medallion” for login

11

{

LoginUser user = UserFactory.getUser(“gold_medallion”);

new LoginPage()

.enterUsername(user.username)

.enterPassword(user.password)

.submitLogin();

}

// “gold_medallion” details defined in a user_data a YAML file...

Page 12: Heuristics to scale your framework

Let’s Solve it! #2

12

Page 13: Heuristics to scale your framework

Add / Modify Libraries

Write a driver wrapper utility

driver defines actions

driver defines setup & teardown

driver takes care of waits

13

Page 14: Heuristics to scale your framework

Sample driverpublic class WebsiteDriver extends BaseDriver{

String DRIVER_KEY;Webdriver driver;

public websitedriver() { DRIVER_KEY = “Web”;driver = new ChromeDriver();

}

public void startURL(String URLString){driver.get(URLString);

}

public void click(WebElement E) {E.click();wait_for_page_load();

} ...}

14

Page 15: Heuristics to scale your framework

Sample architecture

15

Test Case Layer

Step / Method Implementation

iOSDriver

AndroidDriver

WebDriver

Page 16: Heuristics to scale your framework

Let’s Solve it! #3

16

Page 17: Heuristics to scale your framework

Extensibility

Modular code practices

Modular folder structure

Page-Objects or Component-

Objects

Consistency in the

utilities/services 17

Page 18: Heuristics to scale your framework

Page Objects

18

class MyProfile < BasePagedef initialize

pageId = “unique_locator”

field1 = …field2 = …

end

def editProfile// steps to edit profile

endend

PageRegistry.registerPage(MyProfile)

Page 19: Heuristics to scale your framework

Element Hierarchy

19

class ElementType

def self.button(locator)return Button.new(locator)

end

def self.dropdown(locator)return

Dropdown.new(locator)end

def self.checkbox(locator)return

Checkbox.new(locator)end

...end

Page 20: Heuristics to scale your framework

Modular Folders

20

my_test_project- essentials

- data_files- data_models- helpers

- tests- product1- product2

- action_definitions- functionality_based

- framework- page_objects- element_types- tasks

- rake_tasks- shell_scripts

Page 21: Heuristics to scale your framework

Let’s Solve it! #4

21

Page 22: Heuristics to scale your framework

Locators!

Uniquely Identifiable

Prefer CSS Selectors over XPaths

Avoid Long locator expressions

ID over class attributes

Segregate them logically

22

Page 23: Heuristics to scale your framework

Locators that will extend...@submit_button = ElementType.button(

{:web => “#submitButton”,:iOS => “webView

css:’#submitButton’”’,:droid => “webView

css:’#submitButton’”}

23

@coupon_button = ElementType.button({

:web => {:product1 =>

“#applyCouponButton”,:product2 =>

“#enterCouponButton”},...}

Page 24: Heuristics to scale your framework

Let’s Solve it! #5

24

Page 25: Heuristics to scale your framework

Debugging & High Maintenance◻Wrap the failure messages

◻if element.nil? raise “Element not found on <Page>”◻unless loader.nil? raise “Timed out waiting for loader to disappear”

25

◻Say NO to Hacks!◻ No Thread.Sleep◻ No Conditional decisions◻ No monkey patching apis

◻Right set of automated tests◻ No to Carousel/Moving elements◻ No to JS alert box◻ No to external links/apps

Page 26: Heuristics to scale your framework

Thank You@KalgutkarPrasad

26