est automation practice selenium webdriverttk.foxymoron.in/.../2019/10/2_webdriver_java_2015.pdf ·...
TRANSCRIPT
![Page 1: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/1.jpg)
TEST AUTOMATION PRACTICE
WITH SELENIUM WEBDRIVER
Csapó Péter
Mikó Szilárd
EPAM Systems, Budapest, 2015
![Page 2: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/2.jpg)
2CONFIDENTIAL
Basics Agenda
Assertion1
Navigation2
Interrogation3
Manipulation4
![Page 3: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/3.jpg)
3CONFIDENTIAL
Basics 1
ASSERTION
![Page 4: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/4.jpg)
4CONFIDENTIAL
Assertion
Fail method
fail(error_message)
Conditional assert
assertTrue(error_message, boolean_condition)
Equality assert
assertEquals(error_message, expected, actual)
Provide meaningful messages in assertions!
![Page 5: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/5.jpg)
5CONFIDENTIAL
Assertion
Identity assert
assertSame(error_message, expected_object, actual_object)
Custom assert
assertThat(actual_object, Matcher<object> matcher)
String assert
assertThat("myString", containsString("ring"))
Click here for more JUnit assertions
Benefits of assertThat
![Page 6: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/6.jpg)
6CONFIDENTIAL
Basics 2
NAVIGATION
![Page 7: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/7.jpg)
7CONFIDENTIAL
Navigation
• driver.get(java.lang.String)
• driver.navigate().to(java.lang.String)
• driver.navigate().to(java.net.URL)
Loading a web page in current browser window
![Page 8: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/8.jpg)
8CONFIDENTIAL
Navigation
• Driver.Navigate().Back()
• Driver.Navigate().Forward()
Move back & forward
Refresh page
• Driver.Navigate().Refresh()
![Page 9: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/9.jpg)
9CONFIDENTIAL
Basics 3
INTERROGATION
![Page 10: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/10.jpg)
10CONFIDENTIAL
Interrogation
• driver.getTitle()
Window Title
Current URL
Page Source
• driver.getCurrentUrl()
• driver.getPageSource()
![Page 11: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/11.jpg)
11CONFIDENTIAL
Interrogation
• driver.findElement(org.openqa.selenium.By)
– 0 match -> throws exception
– 1 match -> returns a WebElement instance
– 2+ matches -> returns only the first match from web page
• driver.findElements(org.openqa.selenium.By)
– 0 match -> returns an empty list
– 1 match -> returns a list with one WebElement
– 2+ matches -> returns list with all matching WebElements
Locating web elements
![Page 12: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/12.jpg)
12CONFIDENTIAL
Interrogation
• Supports various locator strategies
• By locating mechanisms
– Id
– ClassName
– LinkText
– PartialLinkText
– Name
– TagName
– CssSelector
– XPath
By class
![Page 13: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/13.jpg)
13CONFIDENTIAL
Interrogation
• Firefox
– Firebug add-on (Right click -> Inspect element / F12)
– Firefinder add-on (Try out your CSS & Xpath expressions)
• Chrome
– Built-in (Right click -> Inspect element / F12)
• IE
– Built-in (Tools -> Developer Tools / F12)
Inspecting elements in web browsers
![Page 14: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/14.jpg)
14CONFIDENTIAL
Interrogation
• driver.findElement(By.id(”some_id”));
• Ideal solution, however…
– Ids don’t always exist
– Their uniqueness is not enforced
– Used by developers as well
Id
ClassName
• driver.findElement(By.className(”some_class_name”));
![Page 15: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/15.jpg)
15CONFIDENTIAL
Interrogation
• driver.findElement(By.linkText(”Sign in”));
• driver.findElement(By.partiallinkText(”Sign”));
Linktext
Name
• <input id=”modCustLoginPassword” name=”password”>
• driver.findElement(By.name(”password”));
![Page 16: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/16.jpg)
16CONFIDENTIAL
Interrogation
tagName
• <label>Email address</label>
• driver.findElement(By.tagName(”label”));
Support classes
• Return all that matches each of the locators in sequence
– driver.findElements(new ByChained(by1, by2))
• Return all that matches any of the locators in sequence
– driver.findElements(new ByAll(by1, by2))
![Page 17: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/17.jpg)
17CONFIDENTIAL
Interrogation
CssSelector
• Absolute path
– driver.findElement(By.cssSelector(”html>body>div>p>input”));
• Relative path
– driver.findElement(By.cssSelector(”input”));
• Attribute selection
– driver.findElement(By.cssSelector(”button[name]”));
– driver.findElement(By.cssSelector(”button[name=‚cancel’]”));
– driver.findElement(By.cssSelector(”img:not[alt]”));
![Page 18: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/18.jpg)
18CONFIDENTIAL
Interrogation
CssSelector
• Id selection
– driver.findElement(By.cssSelector(”#save”));
• Class selection
– driver.findElement(By.cssSelector(”.login”));
• Combined selection
– driver.findElement(By.cssSelector(”button#save”));
– driver.findElement(By.cssSelector(”input.login”));
![Page 19: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/19.jpg)
19CONFIDENTIAL
Interrogation
CssSelector
• First matching child of the specified tag
– driver.findElement(By.cssSelector(”div#students:first-child”));
• Nth matching child of the specified tag
– driver.findElement(By.cssSelector(”#loginForm:nth-child(3)”));
• First matching enabled tag
– driver.findElement(By.cssSelector(”button:enabled”));
![Page 20: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/20.jpg)
20CONFIDENTIAL
Interrogation
XPath
• Absolute path
– driver.findElement(By.xpath(”html/body/p/input”));
• Relative path
– driver.findElement(By.xpath(”//input”));
• Attribute selection
– driver.findElement(By.xpath(”//input[@id=’username’]”));
– driver.findElement(By.xpath(”//*[@id=’myId’]”))
![Page 21: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/21.jpg)
21CONFIDENTIAL
Interrogation
Element interrogation
• element.getText();
• element.getAttribute();
• element.getTagName();
• element.isDisplayed();
• element.isEnabled();
• element.isSelected(); -> checkbox is selected or not
• selectElement.isMultiple(); -> multi select listbox or not
• selectElement.getOptions(); -> listbox select options
![Page 22: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/22.jpg)
22CONFIDENTIAL
Basics 4
MANIPULATION
![Page 23: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/23.jpg)
23CONFIDENTIAL
Manipulation
• element.click()
– Button
– Link
– Checkbox
– Combobox
Click
Submit
• form.submit()
– Form
![Page 24: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/24.jpg)
24CONFIDENTIAL
Manipulation
• Actions(driver).keyDown(Keys.SHIFT).click(element).
keyUp(Keys.SHIFT).build().perform();
Shift + Click
Special Actions
• Actions(driver).moveToElement(element).build().perform();
• Actions(driver).contextClick().build().perform();
• Actions(driver).doubleClick().build().perform();
• Actions(driver).clickAndHold().build().perform();
• Actions(driver).release().build().perform();
![Page 25: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/25.jpg)
25CONFIDENTIAL
Manipulation
• element.sendKeys(”string”)
– Input field
Type text
Clear text
• element.clear()
![Page 26: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/26.jpg)
26CONFIDENTIAL
Manipulation
• new Select(element).selectByIndex(elementCount)
Listbox Selection
Listbox Manipulating Commands
• select[ByIndex, ByVisibleText, ByValue]
• deselect[ByIndex, ByVisibleText, ByValue]
• deselectAll()
![Page 27: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/27.jpg)
27CONFIDENTIAL
Questions
![Page 28: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/28.jpg)
28CONFIDENTIAL
Advanced Agenda
Synchronization1
Window Handling2
Screenshots3
Browser Profile4
Cookies5
![Page 29: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/29.jpg)
29CONFIDENTIAL
Advanced 1
SYNCHRONIZATION
![Page 30: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/30.jpg)
30CONFIDENTIAL
Synchronization
• Sets the amount of time to wait for a page load to complete
• Global setting of the Webdriver object
• Negative value means indefinite wait time
Page Load Timeout
Example
• driver.manage().timeouts(). pageLoadTimeout(30, TimeUnit.SECONDS);
![Page 31: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/31.jpg)
31CONFIDENTIAL
Synchronization
• Specifies the waiting time for element not immediately visible
• Global setting of the Webdriver object
• 0 by default
Implicit Wait
Example
• driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
![Page 32: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/32.jpg)
32CONFIDENTIAL
Synchronization
• Waiting for a certain condition
• Poor alternative
– Thread.sleep(1000);
• Recommended
– WebDriverWait class
Explicit Wait
Example
• WebDriverWait wait = new WebDriverWait(driver, TIME_OUT);
• wait.until(ExpectedConditions.method);
![Page 33: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/33.jpg)
33CONFIDENTIAL
Synchronization
• presenceOfElementLocated(By locator)
• textToBePresentInElement(WebElement element, java.lang.String text)
• titleContains(java.lang.String title)
• visibilityOf(WebElement element)
• invisibilityOfElementLocated(By locator)
• elementToBeSelected(WebElement element)
• elementToBeClickable(By locator)
ExpectedConditions class
Click here for more ExpectedConditions
![Page 34: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/34.jpg)
34CONFIDENTIAL
Advanced 2
WINDOW HANDLING
![Page 35: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/35.jpg)
35CONFIDENTIAL
Window Handling
• driver.manage().window().getSize()
• driver.manage().window().setSize(Dimension d);
• driver.manage().window().maximize();
Size
• driver.manage().window().getPosition()
• driver.manage().window().setPosition(Point p);
Position
.getHeight();
.getWidth();
.getX();
.getY();
![Page 36: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/36.jpg)
36CONFIDENTIAL
Window Handling
• String windowHandle = driver.getWindowHandle();
• Iterator<String> windowIterator = browser.getWindowHandles();
Handles
• driver.switchTo().window(windowHandle);
Switch To
![Page 37: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/37.jpg)
37CONFIDENTIAL
Advanced 3
SCREENSHOTS
![Page 38: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/38.jpg)
38CONFIDENTIAL
Screenshots
• Keep track of changing UI
• Store pages with error
Advantages
• File screenshot =
((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
• FileUtils.copyFile(screenshot, new File(fileSource));
Example
![Page 39: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/39.jpg)
39CONFIDENTIAL
Advanced 4
BROWSER PROFILE
![Page 40: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/40.jpg)
40CONFIDENTIAL
Browser Profile
• c:\Users\[user]\AppData\Roaming\Mozilla\Firefox\Profiles\
• Unlimited number of profiles
• Stores many user attributes
– Passwords
– Bookmarks
– Browser history
– Settings
– Etc.
Introduction
![Page 41: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/41.jpg)
41CONFIDENTIAL
Browser Profile
• Set preferred language
• Change User Agent
• Set trusted sites
• Disable confirmation dialog
• Enable Firefox extensions, e.g. Firebug and Firefinder
• Enable native events for drag-and-drop
Usages
![Page 42: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/42.jpg)
42CONFIDENTIAL
Browser Profile
• var profile= new FirefoxProfile();
• profile.setPreference("intl.accept_languages", "de");
• IWebDriver driver = newFirefoxDriver(profile);
• Search for preference keys on Firefox by about:config
• Get all special pages about:about
Set preferred language
![Page 43: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/43.jpg)
43CONFIDENTIAL
Browser Profile
• var profile= new FirefoxProfile();
• profile.setPreference(USERAGENT_OVERRIDE, "Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac
OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314
Safari/531.21.10");
Changing user agent
![Page 44: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/44.jpg)
44CONFIDENTIAL
Browser Profile
• var profile= new FirefoxProfile();
• profile.addExtension(new File(PATH_TO_FIREBUG));
• profile.setPreference("extensions.firebug.currentVersion", "2.0.12");
Enable Extension
![Page 45: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/45.jpg)
45CONFIDENTIAL
Advanced 5
COOKIES
![Page 46: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/46.jpg)
46CONFIDENTIAL
Cookies
• Useful for testing the login feature
• Getting or setting session IDs
• Cookie attributes
– Name
– Value
– Domain
– Path
– Expiry
– Secure
– Http only
Introduction
![Page 47: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/47.jpg)
47CONFIDENTIAL
Cookies
• Get all cookies from the current session
– driver.manage().getCookies();
• Get cookie with a given name
– driver.manage().getCookieNamed(cookieToTest);
Interrogation
![Page 48: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/48.jpg)
48CONFIDENTIAL
Cookies
• Delete all cookies from the current session
– driver.manage().deleteAllCookies()
• Delete a specific cookie
– driver.manage().deleteCookie(TestCookie);
• Delete cookie with a given name
– driver.manage().deleteCookieNamed(cookieToTest);
Manipulation
![Page 49: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/49.jpg)
49CONFIDENTIAL
Cookies
• Add a specific cookie
– Cookie cookie = new Cookie("mycookie", "123456");
– driver.manage().addCookie(cookie);
• Domain attribute is the current document by default
Manipulation
![Page 50: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/50.jpg)
50CONFIDENTIAL
Questions
![Page 51: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/51.jpg)
51CONFIDENTIAL
Test Design Agenda
Data Driven Testing1
Page Object Model2
![Page 52: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/52.jpg)
52CONFIDENTIAL
Test Design 1
DATA DRIVEN TESTING
![Page 53: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/53.jpg)
53CONFIDENTIAL
Data Driven Testing
• Use pre-stored data as input and expected output
• Run your script to get actual output and compare them
• Continue testing with the next set of data
Concept
![Page 54: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/54.jpg)
54CONFIDENTIAL
Data Driven Testing
• Database
• XML file
• Property file
• Etc.
Possible data sources Pros of Data Driven Testing
• Repeatability and reusability
• Separation of test code and data
• Reduction in number of tests
![Page 55: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/55.jpg)
55CONFIDENTIAL
Data Driven Testing
• Testing different localizations of a site
– <testData lang="en" phone="(+36-1) 444 44 99" />
– <testData lang="hu" phone="06 (40) 49 49 49" />
Where to use
![Page 56: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/56.jpg)
56CONFIDENTIAL
Data Driven Testing
• Use JUnitParamsRunner class
– @RunWith(JUnitParamsRunner.class)
– public class Testclass { … }
• Add test parameters
– @Parameters(method = "testData")
– public void testCase(String param1, String param2) { … }
How to use
![Page 57: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/57.jpg)
57CONFIDENTIAL
Test Design 2
PAGE OBJECT MODEL
![Page 58: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/58.jpg)
58CONFIDENTIAL
Page Object Model
• New Approach
• @FindBy annotation
• PageFactory class
• Page Flow
• Best practices
Agenda
![Page 59: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/59.jpg)
59CONFIDENTIAL
Page Object Model
• Every UI change could cause a lot of test maintenance work
• We have to keep maintenance changes as low as possible
• We minimize the change sensitive automation code
New Approach
![Page 60: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/60.jpg)
60CONFIDENTIAL
Page Object Model
• We accept that the application and its elements are bound to change
• We create a new layer which contains change prone data
• This way we can adapt to changes with minimal refactoring cost
How to do it
![Page 61: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/61.jpg)
61CONFIDENTIAL
Page Object Model
• What describes one page should be in one class
• Use class methods to interact with your page
• This class represents your page in the test code
• Divide complex pages into smaller components called widgets
• Create widgets with the same approach as pages
Rules
![Page 62: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/62.jpg)
62CONFIDENTIAL
Page Object Model
• We mark elements with the @FindBy annotation
• FindBy directs Webdriver to locate an element
1. @FindBy(how = How.ID, using = "i")
public WebElement routeFrom;
2. @FindBy(id = "i")
public WebElement routeFrom;
3. public WebElement i;
@FindBy Annotation
![Page 63: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/63.jpg)
63CONFIDENTIAL
Page Object Model
• You can instantiate page/widget WebElements using the PageFactory class
• Use static method initElements
• WebElements are evaluated lazily
PageFactory Class
Example
• PageFactory.initElements(WebDriver driver, java.lang.Class PageObjectClass);
• initElements returns PageObjectClass
![Page 64: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/64.jpg)
64CONFIDENTIAL
Page Object Model
• We want to describe the logical relationship between pages
• Manipulation methods should reflect these relationships
• We should return a page object class after each method
• Return itself if we stay at the same page (e.g. typing)
• Return next page if we navigate (e.g. submit)
Page Flow
![Page 65: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/65.jpg)
65CONFIDENTIAL
Page Object Model
• Create base pages to represent common parts
– E.g. same header, footer, sidebar
• Reuse common widgets in each affected pages
• Use your pages to initiate and confirm the success of navigation
• Put your verification methods inside the page object as well
Best practices
![Page 66: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/66.jpg)
66CONFIDENTIAL
Questions
![Page 67: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/67.jpg)
67CONFIDENTIAL
Cucumber agenda
Understanding Cucumber1
Syntax2
Best practices3
![Page 68: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/68.jpg)
68CONFIDENTIAL
Cucumber 1
UNDERSTANDING
CUCUMBER
![Page 69: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/69.jpg)
69CONFIDENTIAL
• BDD is TDD done right
• Encourages communication between business, QA and dev teams
• Driven by business value
• Extends TDD by using natural language understandable for non
technical people (Given When Then)
• Test cases can even be created by product owners, business
analysts, TPMs.
• Cucumber is the most well known BDD framework.
BDD Quick Recap
![Page 70: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/70.jpg)
70CONFIDENTIAL
Used technologies
![Page 71: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/71.jpg)
71CONFIDENTIAL
Advantages
• Provides a form of documentation (feature file)
• Focus on functionality, operation and behavior
• Test cases are understandable for non-tech stakeholders – common language with
business
• New tests are easy to create by reusing exiting steps
• Plays nicely with TDD, BDD
Disadvantages
• More layers for testers
• More time consuming
Pros and Cons
![Page 72: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/72.jpg)
72CONFIDENTIAL
Cucumber 2
SYNTAX
![Page 73: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/73.jpg)
73CONFIDENTIAL
Feature: A feature would describe the current test script which has to be executed.
Scenario: Scenario describes the steps and expected outcome for a particular test case.
Scenario Outline: Same scenario can be executed for multiple sets of data using scenario
outline. The data is provided by a tabular structure separated by (I I).
Given: It specifies the context of the text to be executed.
And: use this keyword when multiple steps are of the same type are required
When: "When" specifies the test action that has to performed
Then: The expected outcome of the test can be represented by "Then"
But: another way to start your step
Feature Files
![Page 74: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/74.jpg)
74CONFIDENTIAL
In the feature file:
Given the following animals: cow, horse, sheep
Translates to the following code:
@Given("the following animals: (.*)")
public void the_following_animals(List<String> animals) {
//do something terrible
}
Step Definitions
![Page 75: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/75.jpg)
75CONFIDENTIAL
Cucumber in Eclipse
Add JARs to your project
![Page 76: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/76.jpg)
76CONFIDENTIAL
Cucumber in Eclipse
Help -> Install New Software
Work with: Cucumber
![Page 77: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/77.jpg)
77CONFIDENTIAL
@basic
Scenario: Create a search between two cities
Given I open Elvira page
When I create a search from
"Székesfehérvár" to "Sopron"
And I submit the search from
Then the search result title should
contain "Székesfehérvár" and "Sopron"
Basic scenario
![Page 78: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/78.jpg)
78CONFIDENTIAL
Scenario: Create a search between two cities using tables
Given I open Elvira page
When I create a search with the following parameters
| from | Szolnok |
| to | Debrecen |
| via | Hajdúszoboszló |
And I submit the search from
Then the search result title should contain the following city names
| Szolnok |
| Debrecen |
| Hajdúszoboszló |
Tables scenario
![Page 79: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/79.jpg)
79CONFIDENTIAL
Scenario Outline: Create an advanced search between two cities
Given I open Elvira page
When I create a search with the following parameters
| from | <fromCity> |
| to | <toCity> |
| via | <viaCity> |
And I submit the search from
Then the search result title should contain the following city names
| <fromCity> |
| <toCity> |
| <viaCity> |
@tag1
Examples:
| fromCity | toCity | viaCity |
| Szolnok | Debrecen | Hajdúszoboszló |
@tag2
Examples:
| fromCity | toCity | viacity |
| Budapest | Sopron | Tata |
Advanced tables scenario
![Page 80: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/80.jpg)
80CONFIDENTIAL
Cucumber 3
BEST PRACTICES
![Page 81: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/81.jpg)
81CONFIDENTIAL
1. Keep a feature file feature specific
2. Use tags (dependencies, test levels, environments)
Cucumber tips 1
![Page 82: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/82.jpg)
82CONFIDENTIAL
1. Create independent and deterministic scenarios
2. Don’t forget non-happy paths
Cucumber tips 2
![Page 83: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/83.jpg)
83CONFIDENTIAL
1. Follow the one step one thing rule
2. Use nested steps sparsely (calling steps from steps)
Cucumber tips 3
![Page 84: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/84.jpg)
84CONFIDENTIAL
1. Use an object (table) for multiple test data values
– Helps adding, removing test data
2. Use global containers for data used by multiple scenarios
– Helps fast changes (e.g. passwords, ids)
Cucumber tips 4
![Page 85: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/85.jpg)
85CONFIDENTIAL
1. Refactor and Reuse Step Definitions
2. Look for opportunities to generalize
Cucumber tips 5
![Page 86: EST AUTOMATION PRACTICE SELENIUM WEBDRIVERttk.foxymoron.in/.../2019/10/2_Webdriver_Java_2015.pdf · CONFIDENTIAL 73 Feature: A feature would describe the current test script which](https://reader033.vdocuments.us/reader033/viewer/2022051607/6033363f0e21c47a5642347a/html5/thumbnails/86.jpg)
86CONFIDENTIAL
Questions