forked from mayank2193/Java_TestNG_Web-App
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathTestNGAccessibilty.java
208 lines (144 loc) · 7.62 KB
/
TestNGAccessibilty.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package com.lambdatest;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.ITestContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
public class TestNGAccessibilty {
private RemoteWebDriver driver;
private String Status = "failed";
@BeforeMethod
public void setup(Method m, ITestContext ctx) throws MalformedURLException {
String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME");
String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY");
;
String hub = "@hub.lambdatest.com/wd/hub";
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browserName", "Chrome");
caps.setCapability("version", "latest");
caps.setCapability("build", "TestNG With Java");
caps.setCapability("name", m.getName() + this.getClass().getName());
caps.setCapability("plugin", "git-testng");
caps.setCapability("performance",true);
caps.setCapability("network", true);
caps.setCapability("console", true);
caps.setCapability("video", true);
caps.setCapability("w3c", true);
caps.setCapability("accessibility", true);
//caps.setCapability("accessibility.wcagVersion", "wcag21a");
caps.setCapability("accessibility.bestPractice", true);
caps.setCapability("accessibility.needsReview", true);
caps.setCapability("smartUI.project", "par");
String[] Tags = new String[] { "Feature", "Tag", "Moderate" };
caps.setCapability("tags", Tags);
driver = new RemoteWebDriver(new URL("http://" + username + ":" + authkey + hub), caps);
}
@Test
public void basicTest() throws InterruptedException {
String spanText;
System.out.println("Loading Url");
driver.get("https://www.google.com");
driver.executeScript("smartui.takeScreenshot({'screenshotName':'home-page'})");
Thread.sleep(2000);
System.out.println("Checking Box");
driver.findElement(By.name("li1")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li2")).click();
System.out.println("Checking Box");
driver.findElement(By.name("li3")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li4")).click();
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6");
driver.findElement(By.id("addbutton")).click();
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7");
driver.findElement(By.id("addbutton")).click();
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8");
driver.findElement(By.id("addbutton")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li1")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li3")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li7")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li8")).click();
System.out.println("Entering Text");
driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It");
driver.findElement(By.id("addbutton")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li9")).click();
driver.get("https://lambdatest.github.io/sample-todo-app/");
System.out.println("Checking Box");
driver.findElement(By.name("li1")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li2")).click();
System.out.println("Checking Box");
driver.findElement(By.name("li3")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li4")).click();
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6");
driver.findElement(By.id("addbutton")).click();
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7");
driver.findElement(By.id("addbutton")).click();
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8");
driver.findElement(By.id("addbutton")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li1")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li3")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li7")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li8")).click();
System.out.println("Entering Text");
driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It");
driver.findElement(By.id("addbutton")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li9")).click();
driver.get("https://lambdatest.github.io/sample-todo-app/");
System.out.println("Checking Box");
driver.findElement(By.name("li1")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li2")).click();
System.out.println("Checking Box");
driver.findElement(By.name("li3")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li4")).click();
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6");
driver.findElement(By.id("addbutton")).click();
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7");
driver.findElement(By.id("addbutton")).click();
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8");
driver.findElement(By.id("addbutton")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li1")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li3")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li7")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li8")).click();
System.out.println("Entering Text");
driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It");
driver.findElement(By.id("addbutton")).click();
System.out.println("Checking Another Box");
driver.findElement(By.name("li9")).click();
// Let's also assert that the todo we added is present in the list.
spanText = driver.findElement (By.xpath("/html/body/div/div/div/ul/li[9]/span")).getText();
Assert.assertEquals("Get Taste of Lambda and Stick to It", spanText);
Status = "passed";
Thread.sleep(150);
System.out.println("TestFinished");
}
@AfterMethod
public void tearDown() {
driver.executeScript("lambda-status=" + Status);
driver.quit();
}
}