Upload
vodqa
View
104
Download
1
Embed Size (px)
Citation preview
Heuristics to scale your framework
Prasad Kalgutkar
2
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!
Role of Automation
4
On time delivery
Fast Feedbacks
Save time & efforts
Better test coverage
Sanity test builds Accuracy
“ If you automate a mess, you just get an automated mess!
” - Rob Michael
5
Common Challenges
6
➔ Test Data
➔ Add / Modify Libraries
➔ Extensibility
➔ Locators
➔ Debugging
➔ High Maintenance
Let’s Solve it! #1
7
Test Data Management
Keep it simple & understandable
Close to domain
Avoid Excel Sheets
Avoid Fetching from DB
Leverage the tech stack
8
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 =>
Test HashesWhen I enter “VISA” card details
10
def testCards{
:VISA => {
:NUMBER” => “4000100040001000”
:EXPIRY => “2018”
},
:AMEX => {
:NUMBER => “4111311141113111”
:EXPIRY => “2020”
}
}
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...
Let’s Solve it! #2
12
Add / Modify Libraries
Write a driver wrapper utility
driver defines actions
driver defines setup & teardown
driver takes care of waits
13
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
Sample architecture
15
Test Case Layer
Step / Method Implementation
iOSDriver
AndroidDriver
WebDriver
Let’s Solve it! #3
16
Extensibility
Modular code practices
Modular folder structure
Page-Objects or Component-
Objects
Consistency in the
utilities/services 17
Page Objects
18
class MyProfile < BasePagedef initialize
pageId = “unique_locator”
field1 = …field2 = …
end
def editProfile// steps to edit profile
endend
PageRegistry.registerPage(MyProfile)
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
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
Let’s Solve it! #4
21
Locators!
Uniquely Identifiable
Prefer CSS Selectors over XPaths
Avoid Long locator expressions
ID over class attributes
Segregate them logically
22
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”},...}
Let’s Solve it! #5
24
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
Thank You@KalgutkarPrasad
26