Skip to content

Update selenium-4 in Appium Java #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 52 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,36 +124,55 @@ You can update your custom capabilities in test scripts. In this sample project,
<TabItem value="android-config" label="Android" default>

```java
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Galaxy S20");
capabilities.setCapability("platformVersion", "11");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("isRealMobile", true);
capabilities.setCapability("app", "YOUR_APP_URL"); //Enter your app url
capabilities.setCapability("deviceOrientation", "PORTRAIT");
capabilities.setCapability("build", "Java Vanilla - iOS");
capabilities.setCapability("name", "Sample Test Java");
capabilities.setCapability("console", true);
capabilities.setCapability("network", false);
capabilities.setCapability("visual", true);
capabilities.setCapability("devicelog", true);
DesiredCapabilities capabilities = new DesiredCapabilities();
Map<String, Object> ltOptions = new HashMap<>();
ltOptions.put("deviceName", "Galaxy S21+ 5G");
ltOptions.put("app", "APP"); // Enter your app url

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add default app name lt://proverbial-android or lt://proverbial-ios

ltOptions.put("isRealMobile", true);
ltOptions.put("platformVersion", "12");
ltOptions.put("platformName", "Android");
ltOptions.put("deviceOrientation", "PORTRAIT");
ltOptions.put("build", "Java - Android");
ltOptions.put("name", "Sample Test Java-Android");
ltOptions.put("plugin", "LT-Appium-JavaApp");
ltOptions.put("w3c", true);
ltOptions.put("video", true);
ltOptions.put("visual", true);
ltOptions.put("network", true);
ltOptions.put("tunnel", false);
ltOptions.put("project", ""); //Enter Project name here
ltOptions.put("smartUI.project", ""); //Enter smartUI Project name here

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add value in smartUI.project appium-java-real-device

ltOptions.put("smartUI.build": ""); // Enter smartUI buil name here
// ltOptions.put("smartUI.baseline":true);
capabilities.setCapability("lt:options", ltOptions);
```

</TabItem>

<TabItem value="ios-config" label="iOS" default>

```java
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platformVersion", "15");
caps.setCapability("deviceName", "iPhone 12");
caps.setCapability("isRealMobile", true);
caps.setCapability("app", "YOUR_APP_URL"); //Enter your app url
caps.setCapability("platformName", "iOS");
caps.setCapability("build", "Java Vanilla - iOS");
caps.setCapability("name", "Sample Test Java");
caps.setCapability("devicelog", true);
caps.setCapability("network", true);
DesiredCapabilities capabilities = new DesiredCapabilities();
Map<String, Object> ltOptions = new HashMap<>();
ltOptions.put("app", "APP"); // Enter your app url
ltOptions.put("deviceName", "iPhone 14");
ltOptions.put("platformVersion", "16");
ltOptions.put("platformName", "iOS");
ltOptions.put("isRealMobile", true);
ltOptions.put("deviceOrientation", "PORTRAIT");
ltOptions.put("build", "Java Test - iOS");
ltOptions.put("name", "Sample Test Java-iOS");
ltOptions.put("devicelog", true);
ltOptions.put("w3c", true);
ltOptions.put("video", true);
ltOptions.put("visual", true);
ltOptions.put("network", true);
ltOptions.put("tunnel", false);
ltOptions.put("project", ""); //Enter Project name here
ltOptions.put("smartUI.project", ""); // Enter smartUI Project name here
ltOptions.put("smartUI.build": ""); // Enter smartUI buil name here
// ltOptions.put("smartUI.baseline":true);
capabilities.setCapability("lt:options", ltOptions);
```

</TabItem>
Expand All @@ -180,12 +199,22 @@ The tests can be executed in the terminal using the following command:
```bash
mvn test -P android
```
**AndroidWeb:**

```bash
mvn test -P androidweb
```

**iOS:**

```bash
mvn test -P ios
```
**iOSWeb:**

```bash
mvn test -P iosweb
```

**Info:** Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on the :link: [LambdaTest App Automation Dashboard](https://appautomation.lambdatest.com/build?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-java).

Expand Down
64 changes: 56 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
<version>4.5.0</version>
</dependency>


Expand All @@ -42,12 +42,12 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.52.0</version>
<version>4.16.1</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.6.0</version>
<version>8.3.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down Expand Up @@ -86,7 +86,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.141.59</version>
<version>4.13.0</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
Expand Down Expand Up @@ -123,7 +123,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<version>3.0.0</version>
<executions>
<execution>
<phase>test</phase>
Expand All @@ -140,15 +140,38 @@
</plugins>
</build>
</profile>

<profile>
<id>androidweb</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>smartui_androidweb</mainClass>
<classpathScope>test</classpathScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ios</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<version>3.0.0</version>
<executions>
<execution>
<phase>test</phase>
Expand All @@ -165,6 +188,31 @@
</plugins>
</build>
</profile>

<profile>
<id>iosweb</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>smartui_iosweb</mainClass>
<classpathScope>test</classpathScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
</project>
54 changes: 54 additions & 0 deletions src/test/java/smartui_androidweb.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class smartui_androidweb {
public static String userName = System.getenv("LT_USERNAME") == null ? "Your LT Username" // Add username here
: System.getenv("LT_USERNAME");
public static String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" // Add accessKey here
: System.getenv("LT_ACCESS_KEY");
public static void main(String[] args) throws MalformedURLException, InterruptedException {

DesiredCapabilities capabilities = new DesiredCapabilities();
Map<String, Object> ltOptions = new HashMap<>();
ltOptions.put("deviceName", "Galaxy S21+ 5G");
ltOptions.put("isRealMobile", true);
ltOptions.put("platformVersion", "12");
ltOptions.put("platformName", "Android");
ltOptions.put("deviceOrientation", "PORTRAIT");
ltOptions.put("build", "Java - Android-Web");
ltOptions.put("name", "Sample Test Java-Android");
ltOptions.put("plugin", "LT-Appium-Java");
ltOptions.put("w3c", true);
ltOptions.put("video", true);
ltOptions.put("visual", true);
ltOptions.put("network", true);
ltOptions.put("tunnel", false);
ltOptions.put("project", ""); //Enter Project name here
ltOptions.put("smartUI.project", ""); //Enter smartUI Project name here
capabilities.setCapability("lt:options", ltOptions);


AppiumDriver driver = new AppiumDriver(
new URL("https://"+userName+":"+accessKey+"@mobile-hub.lambdatest.com/wd/hub"),
capabilities);
try {
driver.get("https://www.lambdatest.com/");
Thread.sleep(10000);
driver.executeScript("smartui.takeScreenshot=<Name of your Screenshot>");
System.out.println("Screenshot Captured");

driver.quit();
} catch (AssertionError a) {
// ((JavascriptExecutor) driver).executeScript("lambda-status=failed");
a.printStackTrace();
}
}
}


54 changes: 54 additions & 0 deletions src/test/java/smartui_iosweb.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class smartui_iosweb {

public static String userName = System.getenv("LT_USERNAME") == null ? "Your LT Username" // Add username here
: System.getenv("LT_USERNAME");
public static String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" // Add accessKey here
: System.getenv("LT_ACCESS_KEY");


public static void main(String[] args) throws Exception {

DesiredCapabilities capabilities = new DesiredCapabilities();
Map<String, Object> ltOptions = new HashMap<>();
ltOptions.put("deviceName", "iPhone 12");
ltOptions.put("platformVersion", "15");
ltOptions.put("platformName", "iOS");
ltOptions.put("isRealMobile", true);
ltOptions.put("deviceOrientation", "PORTRAIT");
ltOptions.put("build", "Java - iOS-Web");
ltOptions.put("name", "Sample Test Java-iOS");
ltOptions.put("devicelog", true);
ltOptions.put("w3c", true);
ltOptions.put("video", true);
ltOptions.put("visual", true);
ltOptions.put("network", true);
ltOptions.put("tunnel", false);
ltOptions.put("project", ""); //Enter Project name here
ltOptions.put("smartUI.project", ""); //Enter smartUI Project name here
capabilities.setCapability("lt:options", ltOptions);

AppiumDriver driver = new AppiumDriver(
new URL("https://" + userName + ":" + accessKey + "@mobile-hub.lambdatest.com/wd/hub"),
capabilities);

try {

driver.get("https://www.lambdatest.com/");
Thread.sleep(10000);
driver.executeScript("smartui.takeScreenshot=<Name of your Screenshot>");
System.out.println("Screenshot Captured");

// ((JavascriptExecutor) driver).executeScript("lambda-status=passed");
driver.quit();

} catch (Exception t) {
System.out.println(t);
driver.quit();
}
}
}
Loading