-
Notifications
You must be signed in to change notification settings - Fork 26
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
haiderLambdatest
wants to merge
6
commits into
LambdaTest:master
Choose a base branch
from
haiderLambdatest:haider
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add value in |
||
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> | ||
|
@@ -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). | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
orlt://proverbial-ios