Skip to content

Commit 21bb4ea

Browse files
adding web automation (#13)
* adding web automation * removing target folder
1 parent 7e47767 commit 21bb4ea

10 files changed

Lines changed: 268 additions & 2 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323
hs_err_pid*
2424

2525
.DS_Store
26-
.DS_Store
26+
.DS_Store
27+
/.idea/
28+
/target/

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<dependency>
4444
<groupId>io.appium</groupId>
4545
<artifactId>java-client</artifactId>
46-
<version>6.1.0</version>
46+
<version>7.6.0</version>
4747
<scope>test</scope>
4848
</dependency>
4949
</dependencies>
@@ -106,6 +106,40 @@
106106
</build>
107107
</profile>
108108

109+
<profile>
110+
<id>androidWeb</id>
111+
<build>
112+
<plugins>
113+
<plugin>
114+
<groupId>org.apache.maven.plugins</groupId>
115+
<artifactId>maven-surefire-plugin</artifactId>
116+
<configuration>
117+
<includes>
118+
<include>com/lambdatest/androidWeb.java</include>
119+
</includes>
120+
</configuration>
121+
</plugin>
122+
</plugins>
123+
</build>
124+
</profile>
125+
126+
<profile>
127+
<id>iosWeb</id>
128+
<build>
129+
<plugins>
130+
<plugin>
131+
<groupId>org.apache.maven.plugins</groupId>
132+
<artifactId>maven-surefire-plugin</artifactId>
133+
<configuration>
134+
<includes>
135+
<include>com/lambdatest/iosWeb.java</include>
136+
</includes>
137+
</configuration>
138+
</plugin>
139+
</plugins>
140+
</build>
141+
</profile>
142+
109143
</profiles>
110144

111145
</project>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.lambdatest;
2+
3+
import io.appium.java_client.MobileBy;
4+
import org.junit.After;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
import org.openqa.selenium.By;
8+
import org.openqa.selenium.remote.DesiredCapabilities;
9+
import org.openqa.selenium.remote.RemoteWebDriver;
10+
import org.openqa.selenium.support.ui.ExpectedConditions;
11+
import org.openqa.selenium.support.ui.WebDriverWait;
12+
13+
import java.net.MalformedURLException;
14+
import java.net.URL;
15+
16+
public class androidWeb {
17+
18+
String username = System.getenv("LT_USERNAME") == null ? "LT_USERNAME" //Enter the Username here
19+
: System.getenv("LT_USERNAME");
20+
String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "LT_ACCESS_KEY" //Enter the Access key here
21+
: System.getenv("LT_ACCESS_KEY");
22+
public static RemoteWebDriver driver = null;
23+
public String gridURL = "@mobile-hub.lambdatest.com/wd/hub";
24+
public String status = "passed";
25+
@Before
26+
public void setUp() throws Exception {
27+
DesiredCapabilities capabilities = new DesiredCapabilities();
28+
29+
capabilities.setCapability("build", "JUNIT Native Web automation");
30+
capabilities.setCapability("name", "Java JUnit Android Pixel 6");
31+
capabilities.setCapability("platformName", "android");
32+
capabilities.setCapability("deviceName", "Pixel .*"); //Enter the name of the device here
33+
capabilities.setCapability("isRealMobile", true);
34+
capabilities.setCapability("platformVersion","12");
35+
capabilities.setCapability("deviceOrientation", "PORTRAIT");
36+
capabilities.setCapability("console",true);
37+
capabilities.setCapability("network",false);
38+
capabilities.setCapability("visual",true);
39+
try
40+
{
41+
driver = new RemoteWebDriver(new URL("https://" + username + ":" + accessKey + gridURL), capabilities);
42+
}
43+
catch (MalformedURLException e)
44+
{
45+
System.out.println("Invalid grid URL");
46+
} catch (Exception e)
47+
{
48+
System.out.println(e.getMessage());
49+
}
50+
}
51+
52+
@Test
53+
public void testSimple() throws Exception
54+
{
55+
try
56+
{
57+
driver.get("https://mfml.in/api/getInfo");
58+
WebDriverWait wait = new WebDriverWait(driver, 30);
59+
wait.until(ExpectedConditions.elementToBeClickable(By.id("resolution"))).click();
60+
61+
wait.until(ExpectedConditions.elementToBeClickable(By.id("location"))).click();
62+
wait.until(ExpectedConditions.elementToBeClickable(By.id("details"))).click();
63+
wait.until(ExpectedConditions.elementToBeClickable(By.id("timezone"))).click();
64+
65+
status="passed";
66+
}
67+
catch (Exception e)
68+
{
69+
System.out.println(e.getMessage());
70+
status="failed";
71+
}
72+
}
73+
@After
74+
public void tearDown() throws Exception
75+
{
76+
if (driver != null)
77+
{
78+
driver.executeScript("lambda-status=" + status);
79+
driver.quit();
80+
}
81+
}
82+
83+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.lambdatest;
2+
3+
import io.appium.java_client.MobileBy;
4+
import org.junit.After;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
import org.openqa.selenium.By;
8+
import org.openqa.selenium.remote.DesiredCapabilities;
9+
import org.openqa.selenium.remote.RemoteWebDriver;
10+
import org.openqa.selenium.support.ui.ExpectedConditions;
11+
import org.openqa.selenium.support.ui.WebDriverWait;
12+
13+
import java.net.MalformedURLException;
14+
import java.net.URL;
15+
16+
public class iosWeb {
17+
18+
String username = System.getenv("LT_USERNAME") == null ? "LT_USERNAME" //Enter the Username here
19+
: System.getenv("LT_USERNAME");
20+
String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "LT_ACCESS_KEY" //Enter the Access key here
21+
: System.getenv("LT_ACCESS_KEY");
22+
public static RemoteWebDriver driver = null;
23+
public String gridURL = "@mobile-hub.lambdatest.com/wd/hub";
24+
public String status = "passed";
25+
@Before
26+
public void setUp() throws Exception {
27+
DesiredCapabilities capabilities = new DesiredCapabilities();
28+
29+
capabilities.setCapability("build", "JUNIT Native Web automation");
30+
capabilities.setCapability("name", "Java JUnit iOS iPhone 12");
31+
capabilities.setCapability("platformName", "ios");
32+
capabilities.setCapability("deviceName", "iPhone .*");
33+
capabilities.setCapability("isRealMobile", true);
34+
capabilities.setCapability("platformVersion","15");
35+
capabilities.setCapability("deviceOrientation", "PORTRAIT");
36+
capabilities.setCapability("console",true);
37+
capabilities.setCapability("network",false);
38+
capabilities.setCapability("visual",true);
39+
try
40+
{
41+
driver = new RemoteWebDriver(new URL("https://" + username + ":" + accessKey + gridURL), capabilities);
42+
}
43+
catch (MalformedURLException e)
44+
{
45+
System.out.println("Invalid grid URL");
46+
} catch (Exception e)
47+
{
48+
System.out.println(e.getMessage());
49+
}
50+
}
51+
52+
@Test
53+
public void testSimple() throws Exception
54+
{
55+
try
56+
{
57+
driver.get("https://mfml.in/api/getInfo");
58+
WebDriverWait wait = new WebDriverWait(driver, 30);
59+
wait.until(ExpectedConditions.elementToBeClickable(By.id("resolution"))).click();
60+
61+
wait.until(ExpectedConditions.elementToBeClickable(By.id("location"))).click();
62+
wait.until(ExpectedConditions.elementToBeClickable(By.id("details"))).click();
63+
wait.until(ExpectedConditions.elementToBeClickable(By.id("timezone"))).click();
64+
65+
status="passed";
66+
}
67+
catch (Exception e)
68+
{
69+
System.out.println(e.getMessage());
70+
status="failed";
71+
}
72+
}
73+
@After
74+
public void tearDown() throws Exception
75+
{
76+
if (driver != null)
77+
{
78+
driver.executeScript("lambda-status=" + status);
79+
driver.quit();
80+
}
81+
}
82+
83+
}

0 commit comments

Comments
 (0)