future of ui automation testing and jdi
TRANSCRIPT
![Page 1: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/1.jpg)
UI WITH JDIEASY FAST GOOD
24 FEBRUARY 2017
![Page 2: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/2.jpg)
Chief QA AutomationIn Testing more than 11 yearsIn Testing Automation 9 years
ROMAN IOVLEV
![Page 3: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/3.jpg)
3
?
![Page 4: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/4.jpg)
4
JDI SETUP
README
http://jdi.epam.com/
https://github.com/epam/JDI
https://vk.com/jdi_framework
![Page 5: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/5.jpg)
5
<dependency> <groupId>com.epam.jdi</groupId> <artifactId>jdi-uitest-web</artifactId> <version>1.0.58</version></dependency>
JDI SETUP
Maven, Gradle, Ivy
https://github.com/epam/JDI-Examples
https://github.com/epam/JDI README
![Page 6: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/6.jpg)
6
FAQ
![Page 7: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/7.jpg)
7
SIMPLE TEST
PRODUCTPAGE.PRODUCTTYPE.SELECT(«JACKET»); PRODUCTPAGE.PRICE.SELECT(«500$»); PRODUCTPAGE.COLORS.CHECK(«BLACK», «WHITE»);ASSERT.ISTRUE(PRODUCTPAGE.LABEL.GETTEXT(),
«ARMANI JACKET»)
![Page 8: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/8.jpg)
8
SIMPLE TEST
LOGINPAGE.OPEN();LOGINPAGE.LOGINFORM.LOGIN(ADMIN);SEARCHPAGE.SEARCH.FIND(«CUP»);ASSERT.AREEQUAL(RESULTSPAGE.PRODUCTS.COUNT(), EXPECTED);
![Page 9: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/9.jpg)
9
ELEMENTS
SIMPLE COMPLEX COMPOSITE
![Page 10: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/10.jpg)
10
SIMPLE ELEMENTS
![Page 11: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/11.jpg)
11
SIMPLE ELEMENTS
@FINDBY (CSS=“.DESCRIPTION”)PUBLIC TEXT DESCRIPTION;PUBLIC BUTTON SUBMIT;PUBLIC LABEL PRODUCTNAME;PUBLIC LINK FOLLOWME;PUBLIC TEXTFIELD PASSWORD;PUBLIC TEXTAREA ABUSE;PUBLIC CHECKBOX REMEMBERME;PUBLIC DATEPICKER DATE;PUBLIC FILEINPUT UPLOAD;PUBLIC IMAGE PHOTO;
NEWS
![Page 12: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/12.jpg)
12
SIMPLE ELEMENTS
@FINDBY (CSS=“.BTN”) PUBLIC BUTTON SUBMIT;
@FindBy (css=“.btn”)@FindBy (xpath=“//button”)@FindBy (id=“button-id”)@FindBy (name=“button”)@FindBy (css=“.btn”)
public Button submit = new Button(By.css(“.btn”));
@FindBy (css=“.btn”) public IButton submit;
@JFindBy (text=“Submit”)@JFindBy (model=“btn-model”)@JFindBy (binding=“btn”)@JFindBy (repeater=“r-button”)
![Page 13: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/13.jpg)
13
MULTILOCATORS
Multi language testing
@JFindBy (text=“Submit”, group=“en”)@JFindBy (text=“Отправить” , group=“ru”)public Button submit;
Multi version testing
@JFindBy (text=“Submit”, group=“1.7”)@JFindBy (value=“Submit” , group=“2.0”)public Button submit;
![Page 14: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/14.jpg)
14
COMPLEX ELEMENTS
![Page 15: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/15.jpg)
15
COMPLEX ELEMENTS
PUBLIC DROPDOWN COLORS;PUBLIC CHECKLIST SETTINGS;PUBLIC COMBOBOX TAGS;PUBLIC DROPLIST SHIRTSIZES;PUBLIC LIST<ELEMENT> SEARCHRESULTS;PUBLIC ELEMENTS REVIEWS;PUBLIC TABLE PRODUCTS;PUBLIC MENU MAINMENU;PUBLIC TABS AREAS;PUBLIC SELECTOR VOTE;PUBLIC RADIOBUTTONS RATING;PUBLIC TEXTLIST CHAT;
![Page 16: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/16.jpg)
16
COMPLEX ELEMENTS
@JDROPDOWN ( ROOT = @FINDBY(CSS = “.COLORS"), VALUE = @FINDBY(CSS = “.VALUE"), ELEMENTBYNAME = @FINDBY(TAGNAME = “LI"))PUBLIC DROPDOWN COLORS;@JTable( root = @FindBy (css = “.offers"), row = @FindBy (xpath = ".//li[%s]//div"), column = @FindBy (xpath = ".//li//div[%s]"), header = {“ID", “Title", “Apply”} ) public Table offers;
![Page 17: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/17.jpg)
17
COMPLEX ELEMENTS
@FINDBY(CSS = “.COLORS")PUBLIC DROPDOWN COLORS;@FindBy(css = “.table”)public Table offers;
@FindBy(css = “.menu li”)public Menu navigation;@FindBy(css = “.menu ul”)public Menu navigation;@FindBy(xpath = “//*[@class=‘menu’]//li[text()=‘%s’]”)public Menu navigation;
![Page 18: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/18.jpg)
18
USING ENUMS
![Page 19: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/19.jpg)
19
ENUMS IN COMPLEX ELEMENTS
public Menu<Options> topMenu; public enum Options {Home, About, Contacts }
public enum Options {Home(‘option-1’), About(‘option-3’),
public String value; Options (String value) { this.value = value; } @Override public String toString() { return value; }}
public Dropdown<Colors> colors;public Tabs<Areas> areas;public Checklist<Settings> settings;public ComboBox<Tags> tags;public DropList<Sizes> shirtSizes;public Selector<VoteOptions> vote;public RadioButtons<Ratings> rating;
topMenu.select(Options.About);topMenu.select(About);
![Page 20: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/20.jpg)
20
• Code readability• Clear behavior• Union of all element’s locators • Union of element and its actions• Detailed logging
TYPIFIED ELEMENTS
![Page 21: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/21.jpg)
21
Text Description;Button Submit;Label ProductName;Link FollowMe;TextField Password;TextArea Abuse;CheckBox RememberMe;DatePicker Date;FileInput Upload;Image Photo;
WebElement Description;WebElement SubmitButton;WebElement ProductName;WebElement FollowMeLink;WebElement PasswordField;WebElement Abuse;WebElement RememberMe;WebElement DatePicker;WebElement Upload;WebElement Photo;
COMPARE
![Page 22: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/22.jpg)
22
COMPARE
@JDropdown (root = @FindBy(css = “.colors"), value = @FindBy(css = “.value"), elementByName = @FindBy(tagName = “li"))Dropdown Colors;@FindBy(css = “.colors .value")WebElement ColorsValue;@FindBy(css = “.colors li")List<WebElement> ColorsList;
public string getColor() {return ColorsValue.getText();
}
public void selectColor(string colorName) {ColorsValue.Click();for (WebElement color : ColorsList)
if (color.getText().Equals(colorName) {color.Click();return;
}}
![Page 23: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/23.jpg)
23
COMPARE
@FindBy (id = “trades")public Table Colors;
@FindBy(css = "") private List<WebElement> resultsColHeaders;@FindBy(css = "") private List<WebElement> resultsRowsHeaders;@FindBy(css = "") private List<WebElement> resultsCellsHeaders;@FindBy(css = "") private List<WebElement> resultsColumn;@FindBy(css = "") private List<WebElement> resultsRow;
ICell cell(Column column, Row row) { }ICell cell(String columnName, String rowName) { }ICell cell(int columnIndex, int rowIndex) { }List<ICell> cells(String value) { }List<ICell> cellsMatch(String regex) { }ICell cell(String value) { }ICell cellMatch(String regex) { }MapArray<String, MapArray<String, ICell>> rows(String... colNameValues) { }MapArray<String, MapArray<String, ICell>> columns(String... rowNameValues) { }boolean waitValue(String value, Row row) { }boolean waitValue(String value, Column column) { }boolean isEmpty() { }boolean waitHaveRows() { }boolean waitRows(int count) { }ICell cell(String value, Row row) { }ICell cell(String value, Column column) { }List<ICell> cellsMatch(String regex, Row row) { }List<ICell> cellsMatch(String regex, Column
column) { }MapArray<String, ICell> row(String value, Column column) { }MapArray<String, ICell> column(String value, Row row) { }MapArray<String, ICell> row(int rowNum) { }MapArray<String, ICell> row(String rowName) { }List<String> rowValue(int colNum) { }List<String> rowValue(String colName) { }MapArray<String, ICell> column(int colNum) { }MapArray<String, ICell> column(String colName) { }List<String> columnValue(int colNum) { }List<String> columnValue(String colName) { }MapArray<String, SelectElement> header() { }SelectElement header(String name) { }List<String> headers() { }List<String> footer() { }List<ICell> getCells() { }void clean() { }void clear() { }
ITable useCache(boolean value) { }ITable useCache() { }Table clone() { }Table copy() { }ITable hasAllHeaders() { }ITable hasNoHeaders() { }ITable hasOnlyColumnHeaders() { }ITable hasOnlyRowHeaders() { }ITable hasColumnHeaders(List<String> value) { }<THeaders extends Enum> ITable hasColumnHeaders(Class<THeaders> headers) { }ITable hasRowHeaders(List<String> value) { }<THeaders extends Enum> ITable hasRowHeaders(Class<THeaders> headers) { }ITable setColumnsCount(int value) { }ITable setRowsCount(int value) { }
![Page 24: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/24.jpg)
24
COMPOSITE ELEMENTS
![Page 25: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/25.jpg)
25
public class Header extends Section
@JPage(url = "/index.html", title = “Good site")public class HomePage extends WebPage
@JSite(domain = “http://epam.com/")public class EpamSite extends WebSite
public class LoginForm extends Form
public class SearchBar extends Search
public class Alert extends Popup
public class Navigation extends Pagination
COMPOSITE ELEMENTS
![Page 26: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/26.jpg)
26
@JSite(domain = “http://epam.com/")public class EpamSite extends WebSite {
@JPage(url = "/index.html")public static HomePage homepage;@JPage(url = "/login", title = “Login page")public static LoginPage loginPage;@FindBy (css=“.nav”)public static Menu navigation;
}
WEB SITE
@BeforeSuite(alwaysRun = true)public static void setUp() {
WebSite.init(EpamSite.class);}
![Page 27: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/27.jpg)
27
@JPage(url = "/main", title = "Good site", urlTemplate = “/main?\d{10}“, urlCheckType = MATCH, titleCheckType = CONTAINS)
public class HomePage extends WebPage
WEB PAGE
homepage.open(); homepage.checkOpened(); homepage.isOpened();
homepage.refresh();homepage.back();homepage.forward();homepage.addCookie();homepage.clearCache();
USAGE
![Page 28: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/28.jpg)
28
public class Header extends Section {@FindBy (css=“.submit”)public Button submit;@FindBy (css=“.followMe”)
public Link followMe;@FindBy (css=“.navigation”)public Menu navigation;
public void openAbout() {followMe.Click();navigation.select(ABOUT);}
}
SECTION
header.submit.Click(); header.menu.isSelected(); header.openAbout();
USAGE
![Page 29: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/29.jpg)
29
ENTITY DRIVEN TESTING
![Page 30: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/30.jpg)
30
EDT: DATA DRIVEN TESTING
Provide List<User> for test
![Page 31: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/31.jpg)
31
EDT: PRECONDITIONS
Provide List<User> for test0. Have DefaultUser in DB
?+
![Page 32: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/32.jpg)
32
EDT: FILL AND SUBMIT
Provide List<User> for test0. Have DefaultUser in DB1. Login with DefaultUser
![Page 33: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/33.jpg)
33
EDT: FILL AND SEND
Provide List<User> for test0. Have DefaultUser in DB1. Login with DefaultUser2. Submit Contact Us Form for DefaultUser
![Page 34: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/34.jpg)
34
EDT: EXTRACT
Provide List<User> for test0. Have DefaultUser in DB1. Login with DefaultUser2. Submit Contact Us Form for DefaultUser3. Get Act. Opening from Vacancy table
![Page 35: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/35.jpg)
35
EDT: VALIDATE
Provide List<User> for test0. Have DefaultUser in DB1. Login with DefaultUser2. Submit Contact Us Form for DefaultUser3. Get Act. Opening from Vacancy table4. Assert Act. Opening equals to Exp. Opening
ExpectedActual
![Page 36: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/36.jpg)
36
public class LoginForm extends Form<User> {@FindBy (css=“.login”)public TextField login;@FindBy (css=“.psw”)
public TextField password;
@FindBy (css=“.submit”)public Button submit;@FindBy (css=“.cancel”)public Button cancel;
}
FORM
public class User {public String login = “roman”;
public String password = null;}
@Testpublic class simpleTest(User user) { loginForm.login(user); …}
![Page 37: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/37.jpg)
37
@Testpublic void formTest(User admin) {
loginForm.loginAs(admin);filter.select(admin.name);Assert.each(results).contains(admin.name);results.get(1);payForm.submit(admin.creditCard);Assert.areEquals(DB.Transactions.get(1),
admin.creditCard);}
ENTITY DRIVEN TESTING
loginForm.fill(user);loginForm.submit(user);loginForm.verify(user);loginForm.check(user);
loginForm.cancel(user);loginForm.save(user);loginForm.publish(user);loginForm.search(user);loginForm.update(user);…
USAGE
![Page 38: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/38.jpg)
38
• @JTable(• root = @FindBy(className = "search-result-list"),• row = @FindBy(xpath = ".//li[%s]//div"),• column = @FindBy(xpath = ".//li//div[%s]"),• header = {"name", "category", "location", "apply"})• public EntityTable<Job, JobRecord> jobs =• new EntityTable<>(Job.class, JobRecord.class);
![Page 39: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/39.jpg)
39
JobsRow job = jobsPage.jobs.firstRow(r ->textOf(r.title).equals(“Senior QA Engineer”) &&textOf(r.location).equals(“Saint-Petersburg”))
job.apply.agree.click();
List<Job> jobs = jobsPage.jobs.entites(); Assert.entitiesAreEquals(jobs, expectedJobs);
ENTITY TABLES
![Page 40: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/40.jpg)
40
@FindBy(css = ".list.ui-sortable")public Elements<FilmCard> filmCards;
filmCards.get(name).title.getText();
Assert.listEquals(filmCards.asData(Film.class), films);
ELEMENTS
![Page 41: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/41.jpg)
41
OTHER UI OBJECTS
public class SearchBar extends Search { }
public class Navigation extends Pagination { }
public class Confirmation extends Popup { }…public class MyCustom extends CustomObject { } // implements IComposite
![Page 42: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/42.jpg)
42
UI OBJECTS PATTERN
![Page 43: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/43.jpg)
PLATO'S THEORY OF FORMS
5
No application but you can write UI Objects (Page Objects )
IButton
![Page 44: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/44.jpg)
44
PAGE OBJECTS
Tests Page Objects Driver (Engine)
Application
ELEMENTSprivate WebElement UserName;private WebElement Password;private WebElement LoginButton;
• ACTIONS• EnterUserName(String name);• EnterPassword(String name);• ClickLoginButton();
• BUSINESS ACTIONS• Login(User user)
![Page 45: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/45.jpg)
45
PAGE ELEMENTS
ELEMENTSpublic TextField UserName;public TextField Password;public Button LoginButton;
• ACTIONS• ---
• BUSINESS ACTIONS• Login(User user)
ELEMENTpublic DropDown UserStatus;
• ACTIONS• Select(string option)• bool IsSelcted()• List<string> AllOptions()• string GetValue()
![Page 46: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/46.jpg)
46
INTERFACES
![Page 47: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/47.jpg)
47
TEST ANY UI
<dependency> <groupId>com.epam.jdi</groupId> <artifactId>jdi-uitest-web</artifactId> <version>1.0.39</version></dependency>
<dependency> <groupId>com.epam.jdi</groupId> <artifactId>jdi-uitest-gui</artifactId> <version>1.0.39</version></dependency>
<dependency> <groupId>com.epam.jdi</groupId> <artifactId>jdi-uitest-mobile</artifactId> <version>1.0.39</version></dependency>
Selenium
Appium
Sikuli / Winnium
Your Engine (Driver)
![Page 48: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/48.jpg)
48
JDI ARCHITECTURE
Commons
Core
Matchers
Web, Mobile, Gui …
public interface ICheckBox extends IClickable, ISetValue {
void check(); void uncheck(); boolean isChecked();}
INTERFACES
IElementISelectorICompositeIPage
IHasValueISetValue
IButtonICheckBoxIDatePickerIFileInputIImageILabelILinkITextITextAreaITextField
ICheckListIComboBoxIDropDownIDropListIFormIGroupIMenuIPageIPaginationIPopup
IRadioButtonsISearchISelectorITabsITextList
![Page 49: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/49.jpg)
49
INTERFACES
public class Header extends Section {@FindBy (css=“.submit”)public IButton submit;@FindBy (css=“.followMe”)
public ILink followMe;@FindBy (css=“.navigation”)public IMenu navigation;
}
MapInterfaceToElement.update( new Object[][] { { IDropDown.class, MyDropDown.class}, { IButton.class, MyButton.class}, { ITable.class, CustomTable.class} });
![Page 50: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/50.jpg)
50
UI OBJECTS
Page ObjectsPopular test pattern
![Page 51: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/51.jpg)
51
UI OBJECTS
UI ElementsUseful test approach
![Page 52: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/52.jpg)
52
UI OBJECTS
InterfacesFlexible implementation
![Page 53: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/53.jpg)
53
UI OBJECTS
Page Objects UI Elements
Interfaces
UI OBJECTS
![Page 54: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/54.jpg)
54
TEST SETTINGS
![Page 55: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/55.jpg)
55
driver=${browser}domain=${domain}…
TEST PROPERTIES
driver=chrometimeout.wait.element=10domain=https://www.epam.com/driver.getLatest=truesearch.element.strategy=strict | softbrowser.size=1800X1000demo.mode=false | truelog.message.format = shortrun.type=local | remotecache=falsescreenshot.strategy=on fail | on | off
mvn cmd parametres
![Page 56: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/56.jpg)
56
SETTINGS
driver=chrome | firefox | iedrivers.version=2.23driver.getLatest=truebrowser.size=1800X1000 | max | fulldriver.path=C:\\Selenium
DRIVER
timeout.wait.element=10log.message.format=short | fullcache=false | true
elements
demo.mode=false | truedemo.delay=2
DEMO
screenshot.strategy=on fail | on | off
SCREENSHOTS
![Page 57: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/57.jpg)
57
SETTINGS
search.element.strategy=strict | soft | visible, multiple | any, singlevisible - accept only visible elements;any - accepts any elements foundsingle - if found more than 1 element > throw errormultiple - if found more than 1 element > takes first element
strict = visible, singlesoft = any, multiple
SEARCH ELEMENT
![Page 58: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/58.jpg)
58
CUSTOMIZATION
![Page 59: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/59.jpg)
59
public Dropdown<Types> productTypes = new Dropdown<Types>() {
@Override public void selectAction(String name) { super.selectAction(name); label.click(); } };
CUSTOM ACTIONS
![Page 60: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/60.jpg)
60
public class TreeDropdown<T extends Enum> extends Dropdown<T> { … @Override protected void selectAction(String name) { expandAction(); String[] nodes = name.split(" > "); SearchContext context = getDriver(); if (treeLocators.size() >= nodes.length) for (int i=0; i < nodes.length; i++) { String value = nodes[i]; context = first(context.findElements(treeLocators.get(i)),
el -> el.getText().equals(value)); new Clickable((WebElement) context).click(); } }}
CUSTOM ELEMENTS
![Page 61: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/61.jpg)
61
@BeforeSuite (alwaysRun = true)public static void setUp() { ActionScenrios.actionScenario = (element, actionName, jAction, level) -> { logger.info(format("Do '%s' action", actionName)); jAction.invoke(); }; ActionScenrios.resultScenario = (element, actionName, jAction, logResult, level) -> { logger.debug(format("Do '%s' action", actionName)); Object result = jAction.get(); logger.info(format("Get '%s' action result: %s", actionName, result)); return result; };}
CUSTOM SCENARIOS
![Page 62: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/62.jpg)
62
public boolean wait(BooleanSupplier waitCase) { while (!timeoutPassed()) try { if (waitCase.getAsBoolean()) return true; sleep(retryTimeoutInMSec); } catch (Exception ex) {throw new Exception(ex); }
…}
STABLE SEARCH
![Page 63: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/63.jpg)
63
@BeforeSuite (alwaysRun = true)public static void setUp() { SeleniumDriverFactory.elementSearchCriteria =
el -> el.isEnabled() && el.isDisplayed();// el -> el != null;};@Test()public void simpleTest() { sumResult.avatar.localElementSearchCriteria
= el -> !el.getAttribute(“display”).equals(“none”);};
ELEMENT SEARCH
![Page 64: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/64.jpg)
64
PRECONDITIONS
![Page 65: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/65.jpg)
65
NO TEST DEPENDENCIES
@Test(dependsOnMethods = “loginTest”)public void simpleTest() { …};
@Test(dependsOnGroups = “smoke”)public void simpleTest() { …};
![Page 66: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/66.jpg)
66
1. Independent tests2. Time optimization
PRECONDITIONS
PRECONDITION
1. IsInStateCheckAction2. MoveToStateAction
JDI Page precondition
homePage.isOpened();
JDI State precondition
PreconditionsState.isInState(LOGGED_IN)or
isInState(LOGGED_IN)
![Page 67: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/67.jpg)
67
PRECONDITIONS
public enum Preconditions implements IPreconditions { CALC_INIT(() -> calculator.value == 0, () -> { calculator.clear(); calculator.clearMemeory() }), CAREERS_PAGE("/careers"); ….}
![Page 68: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/68.jpg)
68
MATCHERS
![Page 69: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/69.jpg)
69
MODULE STRUCTURE
![Page 70: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/70.jpg)
70
MATCHERS
Assert.contains("Test Text", "Text");Assert.matches("1352-423-85746", "\\d{4}-\\d{3}-\\d{5}");
Assert.arrayEquals(searchResults, expectedResults);Assert.listEquals(orders, expectedOrders);Assert.each(searchResults).contains("IPhone");Assert.each(searchResults).matches("IPhone \\d.*");
Assert.areEquals(() -> getNext(), "IPhone 6");Assert.contains(() -> getNext(), "IPhone 5")
Assert.throwException(this::request, “Bad Request");Assert.hasNoExceptions(this:: request);
![Page 71: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/71.jpg)
71
MATCHERS
new Check(“Search results are correct”).listEquals(searchResults, expectedResults);
ScreenAssert.matches("1352-423-85746", "\\d{4}-\\d{3}-\\d{5}");
Assert.ignoreCase().areEquals(result, "IPhone 6");
Assert.waitTimeout(2).contains(() -> result, "IPhone");
Assert.doScreenshot(SCREEN_ON_FAIL).isTrue(2 * 2 == 4);
Assert.fail(“Houston we have a problem”);throw Assert.exception(“Something goes wrong”);
![Page 72: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/72.jpg)
72
LOGGER
![Page 73: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/73.jpg)
73
LOG4G
Log4J
log4j.rootLogger = info, console
log4j.appender.console = org.apache.log4j.ConsoleAppenderlog4j.appender.console.layout = org.apache.log4j.PatternLayoutlog4j.appender.console.layout.ConversionPattern = %m%n
log4j.rootLogger = debug|error, file, HTML, dailylog
log4j.appender.file=org.apache.log4j.RollingFileAppenderlog4j.appender.file.File=target/.logs/events.loglog4j.appender.file.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n log4j.appender.file.layout=org.apache.log4j.PatternLayout
![Page 74: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/74.jpg)
74
LOGGING JDI
JDISettings.logger = SuperLogger.Logger();
logger.info(“Start tests”);colors.select(BLUE);
[Info] 10:20.154 Start tests[Info] 10:20.220 Select Blue for Selector ‘Colors' (.Selector; css=‘.colors')[Debug] 10:21.004 Get web element for Clickable 'Clickable' (.Clickable; css=‘.colors’)[Debug] 10:21.932 Done
![Page 75: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/75.jpg)
75
LOG IN BDD STYLE
I SELECT ‘JACKET’ PRODUCTTYPE ON PRODUCTPAGEI SELECT ‘500$’ PRICE ON PRODUCTPAGEI CHECK ‘BLACK’ AND ‘WHITE’ COLORS ON PRODUCTPAGE
ProductPage.ProductType.select(«jacket»); ProductPage.Price.select(«500$»); ProductPage.Colors.check(«black», «white»);
![Page 76: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/76.jpg)
76
PARALLEL TEST RUN
![Page 77: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/77.jpg)
77
<?xml version="1.0" encoding="WINDOWS-1251"?><!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"><suite name="Test suite" parallel="methods" thread-count="2"> <test name="Tests" preserve-order="true"> <classes> <class name="com.epam.jdi.uitests.testing.simple.examples.TableExamples"/> <class name="com.epam.jdi.uitests.testing.career.common.tests.CareerTests"/> <class name="com.epam.jdi.uitests.testing.simple.examples.FormExamples"/> </classes> </test></suite>
PARALLEL TEST RUN
![Page 78: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/78.jpg)
78
FUTURE
![Page 79: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/79.jpg)
79
• Chrome plugin• Get ui elements to page object in browser• Auto generation
GENERATED PAGE OBJECTS
public class LoginForm extends Form<User> {@FindBy (css=“.login”)public TextField login;@FindBy (css=“.psw”)
public TextField password;
@FindBy (css=“.submit”)public Button login;
}
![Page 80: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/80.jpg)
80
SERVICES PAGE OBJECTS
@ServiceDomain(“http://service.com”)public class ServiceExample {
@GET (“/color/get”)public RestMethod getColor;@POST (“/color/change/100”)
public RestMethod changeColor;}
Auto generation by WSDL
![Page 81: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/81.jpg)
81
DB TESTING SUPPORT
![Page 82: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/82.jpg)
82
SIMPLE TESTS GENERATOR
![Page 83: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/83.jpg)
83
SUPPORT MAIN UI DEV FRAMEWORKS
![Page 84: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/84.jpg)
84
PERFORMANCE / STATISTIC
![Page 85: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/85.jpg)
85
SNIFF HTTP REQUESTS
![Page 86: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/86.jpg)
86
SUPPORT JS / PHYTON
![Page 87: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/87.jpg)
87
ENJOY
![Page 88: Future of UI Automation testing and JDI](https://reader035.vdocuments.us/reader035/viewer/2022062218/58d1355e1a28abe3298b6331/html5/thumbnails/88.jpg)
88
CONTACTS
http://jdi.epam.com/
https://vk.com/jdi_framework
https://github.com/epam/JDI
• UI Objects• typified Elements • typified Objects
• Entity Driven testing• Interfaces