jdi 2.0. not only ui testing

32
JDI – NOT ONLY UI 22 OCTOBER 2017

Upload: comaqaby

Post on 22-Jan-2018

46 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: JDI 2.0. Not only UI testing

JDI – NOT ONLY UI

22 OCTOBER 2017

Page 2: JDI 2.0. Not only UI testing

Chief QA Automation

In Testing more than 12 years

In Testing Automation 10 years

ROMAN IOVLEV

roman.Iovlev

[email protected]

Page 3: JDI 2.0. Not only UI testing

3

?

Page 4: JDI 2.0. Not only UI testing

•UI Test Framework

•UI Elements oriented• Dozens of UI elements already implemented• Most of common problems already solved (e.g.

stabilization)

4

JDI

Page 5: JDI 2.0. Not only UI testing

•UI Test Framework

•UI Elements oriented

5

JDI

Page 6: JDI 2.0. Not only UI testing

•UI Test Framework

•UI Elements oriented

• Interfaces above engines

6

JDI

Page 7: JDI 2.0. Not only UI testing

JDI HTTP

7

Page 8: JDI 2.0. Not only UI testing

@ServiceDomain("http://httpbin.org/")

public class UserService {

@GET("/get") static RestMethod getUser;

@POST("/post") RestMethod updateSettings;

@PUT("/put") RestMethod addUser;

@PATCH("/patch") RestMethod patch;

@DELETE("/delete") RestMethod removeUser;

8

JDI HTTP

Page 9: JDI 2.0. Not only UI testing

@ServiceDomain("http://httpbin.org/")

public class UserService {

@GET("/get") static M getUser;

@POST("/post") M updateSettings;

@PUT("/put") M addUser;

@PATCH("/patch") M patch;

@DELETE("/delete") M removeUser;

9

JDI HTTP

Page 10: JDI 2.0. Not only UI testing

UserService.addUser.call();

RestResponse resp = getUser.call();

assertEquals(resp.status, 200);

assertEquals(resp.statusType, OK);

assertEquals(resp.body(“name"), “Roman");

resp.assertThat(). body("url", equalTo("http://httpbin.org/get"))

resp.assertThat().header("Connection", "keep-alive");

10

JDI HTTP

Page 11: JDI 2.0. Not only UI testing

app.addUser.send(user);

User actualUser = app.getUser.asData(User.class);

assertEquals(actualUser, user);

11

JDI HTTP

Entities

@ServiceDomain ("http://httpbin.org/")

public class UserService {

@GET ("/get") RestMethod<User> getUser;

@PUT ("/put") RestMethod<User> addUser;

Page 12: JDI 2.0. Not only UI testing

@ServiceDomain("http://httpbin.org/")

public class UserService {

@ContentType(JSON)

@Headers({

@Header(name = "Name", value = "Roman"),

@Header(name = "Id", value = "Test")

}) @GET("/get") M getUser;

12

JDI HTTP

Page 13: JDI 2.0. Not only UI testing

JDI LIGHT SABER

13

Page 14: JDI 2.0. Not only UI testing

BiConsumer<T,U>, BiFunction<T,U,R>, BinaryOperator<T>, BiPredicate<T,U>, Consumer<T>, Function<T,R>, Predicate<T>, Supplier<T>, UnaryOperator<T>…

14

LIGHT SABER

Lambda: Functional interfaces

for (int i=0;i<10;i++)

click.invoke();

JAVA 8

click = () -> element.click();

Page 15: JDI 2.0. Not only UI testing

JAction, JAction1, JAction2, …, JAction9

JFunc, JFunc1, JFunc2, …, JFunc9

15

LIGHT SABER

Lambda: Functional interfaces

JAction click = () -> element.click();

JAction1<WebDriver> close = driver -> driver.quit();

JFunc3<String[], Integer, Boolean, String> func =

(array, index, flag) -> flag ? array[index] : “none”;

Page 16: JDI 2.0. Not only UI testing

List<Integer> list = asList(1, 3, 2, 6)

16

LIGHT SABER

Stream

List<Integer> even = list.stream()

.filter(i -> i % 2 == 0).collect(Collectors.toList());

List<Integer> even = filter(list, i -> i % 2 == 0);

List<String> nums = map(list, i -> “№”+i);

Boolean hasOdds = any(list, i -> i%2 > 0);

LinqUtils

Page 17: JDI 2.0. Not only UI testing

Integer firstNum = first(list);

17

LIGHT SABER

Integer lastNum = last(list);

listCopy(list, 2, 4);

selectMany(list, i -> asList(i,i*2));

listEquals(asList(1,4,3), asList(3,4,1));

first(list, i -> i > 2);

last(list, I -> i<4);

get(asList(3,4,5,2,3,4,2,1), -3);

LinqUtils

Page 18: JDI 2.0. Not only UI testing

public class User extends DataClass {

public String name;

public String psw;

}

18

LIGHT SABER

DataClass

user.toString() -> User(name=epam;psw=1234)

assertEquals(actualUser, expectedUser);

Map<String,Object> fields=user.asMap();

Page 19: JDI 2.0. Not only UI testing

public class User extends DataClass<User> {

public String name, lastName, nick, description, position;

public Integer id, cardNum, passSeries;

}

19

LIGHT SABER

user.set(u -> u.nick = “Supreme”);

user.set(u->{u.id = 32;u.position=“God”;nick=“Thor”;});

DataClass

Page 20: JDI 2.0. Not only UI testing

print(list);

20

LIGHT SABER

PrintUtils

-> “a,b,c”

print(list, “; ”,”{%s}”); -> “{a}; {b}; {c}”

printFields(user); -> “User(name:epam;psw:admin)”

print(nums,n->”(”+n+”)”); -> “(1)(3)(2)(8)”

Page 21: JDI 2.0. Not only UI testing

public String process(List<String> list) {…}

public String process(String[] array) {…}

public String process(Map<String,Integer> map) {…}

21

LIGHT SABER

Java Collections

Map<String, Integer> map = new HashMap<>();

map.put(“A”,1); map.put(“B”,3); map.put(“C”,100500);

map.put(“D”,-1); map.put(“E”,777); map.put(“F”,2);

Page 22: JDI 2.0. Not only UI testing

public String process(List<String> list) {…}

process(new MapArray());

22

LIGHT SABER

MapArray

MapArray<String, Integer> map

= new MapArray<>(new Object[][]

{{“A”,1},{“B”,3},{“C”,100500},{“D”,-1},{“E”,777},{“F”,2}});

LinqUtils

map.get(3); map.revert();map.get(-2);

Page 23: JDI 2.0. Not only UI testing

PAGE OBJECTS

GEENRATOR

23

Page 24: JDI 2.0. Not only UI testing

new PageObjectsGenerator(rules, urls, output, package)

.generatePageObjects();

24

PAGE OBJECTS GENERATOR LIBRARY

RULES

https://domain.com/https://domain.com/loginhttps://domain.com/shophttps://domain.com/about

URLS

{"elements": [{"type":"Button","name": “value","css": “input[type=button]"},

…]}

OUTPUT

src/main/java

PACKAGE

com.domain

Page 25: JDI 2.0. Not only UI testing

<input type=“button” value=“Next”>

<input type=“button” value=“Previous”>

<button class=“btn”>Submit</button>

25

PAGE OBJECTS GENERATOR LIBRARY

"type":"Button",

"name": “value",

"css": “input[type=button]“

"type":"Button",

"name": “text",

"css": “button.btn"

@Findby(css=“input[type=button][value=Next]”)

public Button next;

@Findby(css=“input[type=button][value=Previous]”)

public Button previous;

@Findby(xpath=“//button[@class=‘btn’

and text()=‘Submit’]”)

public Button submit;

Page 26: JDI 2.0. Not only UI testing

VERIFY LAYOUT

26

Page 27: JDI 2.0. Not only UI testing

@Image(“/src/test/resources/submitbtn.png”)

@FindBy(text = “Submit”)

public Button submit;

27

VERIFY LAYOUT

Page 28: JDI 2.0. Not only UI testing

@Image(“/src/test/resources/submitbtn.png”)

@FindBy(text = “Submit”)

public Button submit;

28

VERIFY LAYOUT

submit.isDisplayed();

submit.assertDisplayed();

Page 29: JDI 2.0. Not only UI testing

@ImagesFolder(“/src/test/resources/imgs”)

public EpamSite extends WebSite;

29

VERIFY LAYOUT

@Image(“submitbtn.png”)

@FindBy(text = “Submit”)

public Button submit;

Page 30: JDI 2.0. Not only UI testing

public class EpamSite extends WebSite {

public static HomePage homePage;

30

VERIFY LAYOUT

public class HomePage extends WebPage

@FindBy(text = “Submit”)

public Button submit;

“src/test/resources/jdi-images/epamsite/homepage/submit.jpg”

Page 31: JDI 2.0. Not only UI testing

31

VERIFY LAYOUT

homePage.verifyLayout()

homePage.assertLayout() / homePage.checkLayout()

public class EpamSite extends WebSite {

public static HomePage homePage;

public class HomePage extends WebPage

@FindBy(text = “Submit”)

public Button submit;

Page 32: JDI 2.0. Not only UI testing

32

JDI SETUP

README

http://jdi.epam.com/

https://github.com/epam/JDI

https://vk.com/jdi_framework