Skip to content

Commit 5744d91

Browse files
committed
real mobile changes
1 parent d7d8225 commit 5744d91

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

mobile.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
3+
<suite thread-count="1" parallel="tests" name="Suite">
4+
<test thread-count="1" parallel="classes" name="Test">
5+
<classes>
6+
<class name="com.lambdatest.TestNGTodoMobile"/>
7+
</classes>
8+
</test> <!-- Test -->
9+
</suite> <!-- Suite -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package com.lambdatest;
2+
3+
import java.lang.reflect.Method;
4+
import java.net.MalformedURLException;
5+
import java.net.URL;
6+
7+
import org.openqa.selenium.By;
8+
import org.openqa.selenium.remote.DesiredCapabilities;
9+
import org.openqa.selenium.remote.RemoteWebDriver;
10+
import org.testng.Assert;
11+
import org.testng.ITestContext;
12+
import org.testng.annotations.AfterMethod;
13+
import org.testng.annotations.BeforeMethod;
14+
import org.testng.annotations.Test;
15+
16+
public class TestNGTodoMobile {
17+
18+
private RemoteWebDriver driver;
19+
private String Status = "failed";
20+
21+
@BeforeMethod
22+
public void setup(Method m, ITestContext ctx) throws MalformedURLException {
23+
String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME");
24+
String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY");
25+
;
26+
String hub = "@hub.lambdatest.com/wd/hub";
27+
28+
DesiredCapabilities caps = new DesiredCapabilities();
29+
caps.setCapability("deviceName", "Google Pixel 4a");
30+
caps.setCapability("build", "TestNG With Java");
31+
caps.setCapability("name", m.getName() + this.getClass().getName());
32+
caps.setCapability("plugin", "git-testng");
33+
caps.setCapability("isRealMobile", true);
34+
35+
String[] Tags = new String[] { "Feature", "Tag", "Moderate" };
36+
caps.setCapability("tags", Tags);
37+
38+
driver = new RemoteWebDriver(new URL("https://" + username + ":" + authkey + hub), caps);
39+
}
40+
41+
@Test
42+
public void basicTest() throws InterruptedException {
43+
String spanText;
44+
System.out.println("Loading Url");
45+
Thread.sleep(100);
46+
driver.get("https://lambdatest.github.io/sample-todo-app/");
47+
48+
System.out.println("Checking Box");
49+
driver.findElement(By.name("li1")).click();
50+
51+
System.out.println("Checking Another Box");
52+
driver.findElement(By.name("li2")).click();
53+
54+
System.out.println("Checking Box");
55+
driver.findElement(By.name("li3")).click();
56+
57+
System.out.println("Checking Another Box");
58+
driver.findElement(By.name("li4")).click();
59+
60+
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6");
61+
driver.findElement(By.id("addbutton")).click();
62+
63+
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7");
64+
driver.findElement(By.id("addbutton")).click();
65+
66+
driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8");
67+
driver.findElement(By.id("addbutton")).click();
68+
69+
System.out.println("Checking Another Box");
70+
driver.findElement(By.name("li1")).click();
71+
72+
System.out.println("Checking Another Box");
73+
driver.findElement(By.name("li3")).click();
74+
75+
System.out.println("Checking Another Box");
76+
driver.findElement(By.name("li7")).click();
77+
78+
System.out.println("Checking Another Box");
79+
driver.findElement(By.name("li8")).click();
80+
81+
System.out.println("Entering Text");
82+
driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It");
83+
84+
driver.findElement(By.id("addbutton")).click();
85+
86+
System.out.println("Checking Another Box");
87+
driver.findElement(By.name("li9")).click();
88+
89+
// Let's also assert that the todo we added is present in the list.
90+
91+
spanText = driver.findElementByXPath("/html/body/div/div/div/ul/li[9]/span").getText();
92+
Assert.assertEquals("Get Taste of Lambda and Stick to It", spanText);
93+
Status = "passed";
94+
Thread.sleep(800);
95+
96+
System.out.println("TestFinished");
97+
98+
}
99+
100+
@AfterMethod
101+
public void tearDown() {
102+
driver.executeScript("lambda-status=" + Status);
103+
driver.quit();
104+
}
105+
106+
}

0 commit comments

Comments
 (0)