-
Notifications
You must be signed in to change notification settings - Fork 27
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 4 commits
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
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,70 @@ | ||
| import io.appium.java_client.AppiumBy; | ||
| 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_android { | ||
| public static String userName = System.getenv("LT_USERNAME") == null ? "YOUR_USERNAME" // Add username here | ||
| : System.getenv("LT_USERNAME"); | ||
| public static String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "YOUR_USERNAME" // 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("app", "lt://proverbial-android"); // Enter your app url | ||
| ltOptions.put("isRealMobile", true); | ||
| ltOptions.put("platformName", "Android"); | ||
| ltOptions.put("build", "Java - Android"); | ||
| ltOptions.put("name", "Sample Test Java-Android"); | ||
| ltOptions.put("w3c", true); | ||
| ltOptions.put("video", true); | ||
| ltOptions.put("visual", true); | ||
| ltOptions.put("smartUI.project", "Real-Device-Project-Android"); // Enter your smartUI Project name | ||
| capabilities.setCapability("lt:options", ltOptions); | ||
|
|
||
|
|
||
| AppiumDriver driver = new AppiumDriver( | ||
| new URL("https://"+userName+":"+accessKey+"@mobile-hub.lambdatest.com/wd/hub"), | ||
| capabilities); | ||
| try { | ||
|
|
||
| driver.findElement(AppiumBy.id("com.lambdatest.proverbial:id/color")).click(); | ||
|
|
||
| //Changes the text to proverbial | ||
| driver.findElement(AppiumBy.id("com.lambdatest.proverbial:id/Text")).click(); | ||
|
|
||
| //toast is visible | ||
| driver.findElement(AppiumBy.id("com.lambdatest.proverbial:id/toast")).click(); | ||
|
|
||
| //notification is visible | ||
| driver.findElement(AppiumBy.id("com.lambdatest.proverbial:id/notification")).click(); | ||
|
|
||
| //takes back to home page | ||
| driver.findElement(AppiumBy.accessibilityId("Home")).click(); | ||
| driver.navigate().back(); | ||
| Thread.sleep(2000); | ||
|
|
||
| //Takes to speed test page | ||
| driver.findElement(AppiumBy.id("com.lambdatest.proverbial:id/speedTest")).click(); | ||
| Thread.sleep(5000); | ||
| driver.navigate().back(); | ||
|
|
||
| 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,48 @@ | ||
|
|
||
| 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_USERNAME" // Add username here | ||
| : System.getenv("LT_USERNAME"); | ||
| public static String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "YOUR_ACCESS_KEY" // 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("platformName", "Android"); | ||
| ltOptions.put("build", "Java - Android-Web"); | ||
| ltOptions.put("name", "Sample Test Java-Android"); | ||
| ltOptions.put("w3c", true); | ||
| ltOptions.put("video", true); | ||
| ltOptions.put("visual", true); | ||
| ltOptions.put("smartUI.project", "Real-Device-Project-Android-Web"); // Enter your smartUI Project name | ||
| 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(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
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.
@haiderLambdatest Class Name in Java, Can't start with LowerCase