-
Notifications
You must be signed in to change notification settings - Fork 80
/
NestedViewsTest.java
96 lines (78 loc) · 2.78 KB
/
NestedViewsTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package Tests;
import Pages.NestedViewsPage;
import Tests.AbstractBaseTests.TestBase;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
/**
* Tests for nested views
*/
public class NestedViewsTest extends TestBase {
private NestedViewsPage nestedViewsPage;
private static final String UP_MESSAGE_1 = "Press to go to the next level";
private static final String UP_MESSAGE_2 = "Final Level";
private static final int NUMBER_NEXT_BACK_BUTTON = 8;
private static final int NUMBER_BACK_BUTTON = 6;
private static final String NEXT_BACK_BUTTON_COUNTER_BEFORE = "9";
private static final String NEXT_BACK_BUTTON_COUNTER_AFTER = "3";
@Override
public String getName() {
return "Nested Views";
}
@BeforeTest
@Override
public void setUpPage() {
nestedViewsPage = new NestedViewsPage(driver);
}
/**
* Tests the back button by going up a specific amount,
* going back to a by a specific amount, and then asserting
* the difference
*/
@Test
public void testBackButton() {
nestedViewsPage.pressBackButtonCategory();
for (int i = 0; i < NUMBER_NEXT_BACK_BUTTON; i++) {
nestedViewsPage.pressNextBackButton();
}
Assert.assertEquals(nestedViewsPage.getCounter(), NEXT_BACK_BUTTON_COUNTER_BEFORE);
for (int i = 0; i < NUMBER_BACK_BUTTON; i++) {
nestedViewsPage.pressBackButton();
}
Assert.assertEquals(nestedViewsPage.getCounter(), NEXT_BACK_BUTTON_COUNTER_AFTER);
}
/**
* Tests the up button by going up
*/
@Test
public void testUpButton() {
nestedViewsPage.pressUpButtonCategory();
Assert.assertEquals(nestedViewsPage.getUpMessage(), UP_MESSAGE_1);
nestedViewsPage.pressNextUpButton();
Assert.assertEquals(nestedViewsPage.getUpMessage(), UP_MESSAGE_2);
nestedViewsPage.navigateUp();
Assert.assertEquals(nestedViewsPage.getUpMessage(), UP_MESSAGE_1);
}
/**
* Navigate up to reset the test
*/
@AfterMethod
public void goBackToMenu() {
nestedViewsPage.navigateUp();
}
}