-
Notifications
You must be signed in to change notification settings - Fork 9
Synchronize driver variables and correct Cucumber resource locations #4
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,129 +1,112 @@ | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>Cucumber-Selenium-TestNG</groupId> | ||
| <artifactId>CucumberTestNG</artifactId> | ||
| <version>0.0.1-SNAPSHOT</version> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <name>CucumberTestNG</name> | ||
| <url>http://maven.apache.org</url> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| </properties> | ||
|
|
||
|
|
||
| <dependencies> | ||
|
|
||
| <dependency> | ||
| <groupId>org.testng</groupId> | ||
| <artifactId>testng</artifactId> | ||
| <version>7.6.1</version> | ||
| </dependency> | ||
|
|
||
|
|
||
| <dependency> | ||
| <groupId>org.seleniumhq.selenium</groupId> | ||
| <artifactId>selenium-java</artifactId> | ||
| <version>3.141.59</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.cucumber</groupId> | ||
| <artifactId>cucumber-java</artifactId> | ||
| <version>7.4.1</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.cucumber</groupId> | ||
| <artifactId>cucumber-picocontainer</artifactId> | ||
| <version>7.4.1</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.cucumber</groupId> | ||
| <artifactId>cucumber-core</artifactId> | ||
| <version>7.4.1</version> | ||
| </dependency> | ||
|
|
||
| <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng --> | ||
| <dependency> | ||
| <groupId>io.cucumber</groupId> | ||
| <artifactId>cucumber-testng</artifactId> | ||
| <version>7.4.1</version> | ||
| </dependency> | ||
|
|
||
| <!-- <dependency> | ||
| <groupId>net.masterthought</groupId> | ||
| <artifactId>cucumber-reporting</artifactId> | ||
| <version>3.8.0</version> | ||
| </dependency> --> | ||
| <!-- <dependency> | ||
| <groupId>org.jetbrains</groupId> | ||
| <artifactId>annotations</artifactId> | ||
| <version>RELEASE</version> | ||
| <scope>compile</scope> | ||
| </dependency> --> | ||
|
|
||
| </dependencies> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.6.1</version> | ||
| <configuration> | ||
| <source>1.8</source> | ||
| <target>1.8</target> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
|
|
||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-resources-plugin</artifactId> | ||
| <version>2.4</version> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>2.19.1</version> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>test</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <suiteXmlFiles> | ||
| <!--suppress UnresolvedMavenProperty --> | ||
| <suiteXmlFile>${suite}</suiteXmlFile> | ||
| </suiteXmlFiles> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>net.masterthought</groupId> | ||
| <artifactId>maven-cucumber-reporting</artifactId> | ||
| <version>3.15.0</version> | ||
| <executions> | ||
| <execution> | ||
| <id>execution</id> | ||
| <phase>verify</phase> | ||
| <goals> | ||
| <goal>generate</goal> | ||
| </goals> | ||
| <configuration> | ||
| <projectName>LambdatestTodoSample</projectName> | ||
| <outputDirectory>target/cucumber-reports/advanced-reports</outputDirectory> | ||
| <cucumberOutput>target/cucumber-reports/CucumberTestReport.json</cucumberOutput> | ||
| <buildNumber>1</buildNumber> | ||
| <parallelTesting>true</parallelTesting> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | ||
| http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
|
||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>Cucumber-Appium-TestNG</groupId> | ||
| <artifactId>LT-Appium-Cucumber</artifactId> | ||
| <version>1.0.0</version> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <name>LT Appium Cucumber TestNG</name> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
|
|
||
| <!-- Java --> | ||
| <maven.compiler.source>11</maven.compiler.source> | ||
| <maven.compiler.target>11</maven.compiler.target> | ||
|
|
||
| <!-- Core Versions --> | ||
| <appium.java.client.version>9.1.0</appium.java.client.version> | ||
| <selenium.version>4.18.1</selenium.version> | ||
| <cucumber.version>7.15.0</cucumber.version> | ||
| <testng.version>7.9.0</testng.version> | ||
| <slf4j.version>2.0.9</slf4j.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
|
|
||
| <!-- Appium --> | ||
| <dependency> | ||
| <groupId>io.appium</groupId> | ||
| <artifactId>java-client</artifactId> | ||
| <version>${appium.java.client.version}</version> | ||
| </dependency> | ||
|
|
||
| <!-- Selenium --> | ||
| <dependency> | ||
| <groupId>org.seleniumhq.selenium</groupId> | ||
| <artifactId>selenium-java</artifactId> | ||
| <version>${selenium.version}</version> | ||
| </dependency> | ||
|
|
||
| <!-- TestNG --> | ||
| <dependency> | ||
| <groupId>org.testng</groupId> | ||
| <artifactId>testng</artifactId> | ||
| <version>${testng.version}</version> | ||
| </dependency> | ||
|
|
||
|
|
||
| <!-- Cucumber --> | ||
| <dependency> | ||
| <groupId>io.cucumber</groupId> | ||
| <artifactId>cucumber-java</artifactId> | ||
| <version>${cucumber.version}</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.cucumber</groupId> | ||
| <artifactId>cucumber-testng</artifactId> | ||
| <version>${cucumber.version}</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.cucumber</groupId> | ||
| <artifactId>cucumber-picocontainer</artifactId> | ||
| <version>${cucumber.version}</version> | ||
| </dependency> | ||
|
|
||
| <!-- Logging --> | ||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-simple</artifactId> | ||
| <version>${slf4j.version}</version> | ||
| </dependency> | ||
|
|
||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
|
|
||
| <!-- Compiler --> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.11.0</version> | ||
| <configuration> | ||
| <source>11</source> | ||
| <target>11</target> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <!-- TestNG Runner --> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>3.2.5</version> | ||
| <configuration> | ||
| <suiteXmlFiles> | ||
| <suiteXmlFile>${suite}</suiteXmlFile> | ||
| </suiteXmlFiles> | ||
| <testFailureIgnore>false</testFailureIgnore> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| </plugins> | ||
| </build> | ||
|
|
||
| </project> |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,67 +1,63 @@ | ||||||
| package MyRunner; | ||||||
|
|
||||||
| import java.net.URL; | ||||||
|
|
||||||
| import io.appium.java_client.android.options.UiAutomator2Options; | ||||||
| import io.cucumber.testng.AbstractTestNGCucumberTests; | ||||||
| import io.cucumber.testng.CucumberOptions; | ||||||
| import io.cucumber.testng.TestNGCucumberRunner; | ||||||
| import org.openqa.selenium.remote.DesiredCapabilities; | ||||||
| import org.openqa.selenium.remote.RemoteWebDriver; | ||||||
| import org.testng.annotations.AfterClass; | ||||||
| import org.testng.annotations.BeforeClass; | ||||||
| import org.testng.annotations.BeforeMethod; | ||||||
| import org.testng.annotations.DataProvider; | ||||||
| import org.testng.annotations.Parameters; | ||||||
|
|
||||||
| @CucumberOptions(features = "src/main/java/Features/todo.feature", glue = { | ||||||
| "stepDefinitions"}, plugin = "json:target/cucumber-reports/CucumberTestReport.json") | ||||||
|
|
||||||
| import java.net.URL; | ||||||
| import java.util.HashMap; | ||||||
| import java.util.Map; | ||||||
|
|
||||||
| @CucumberOptions( | ||||||
| // Pointing to the actual location seen in your file tree | ||||||
| features = "src/main/java/resources/features", | ||||||
| glue = {"stepDefinitions"}, | ||||||
| plugin = { | ||||||
| "pretty", | ||||||
| "html:target/cucumber-report.html" | ||||||
| }, | ||||||
| monochrome = true | ||||||
| ) | ||||||
| public class TestRunner extends AbstractTestNGCucumberTests { | ||||||
|
|
||||||
| private TestNGCucumberRunner testNGCucumberRunner; | ||||||
|
|
||||||
| public static RemoteWebDriver connection; | ||||||
| public static RemoteWebDriver driver; // Changed to public static for easier access in Hook | ||||||
|
|
||||||
| @BeforeClass(alwaysRun = true) | ||||||
| public void setUpCucumber() { | ||||||
| testNGCucumberRunner = new TestNGCucumberRunner(this.getClass()); | ||||||
| } | ||||||
|
|
||||||
| @BeforeMethod(alwaysRun = true) | ||||||
| @Parameters({"deviceName", "platformVersion", "platformName"}) | ||||||
| public void setUpClass(String deviceName, String platformVersion, String platformName) throws Exception { | ||||||
|
|
||||||
| String username = System.getenv("LT_USERNAME") == null ? "YOUR_LT_USERNAME" : System.getenv("LT_USERNAME"); //Enter your LambdaTest username at the place of YOUR_LT_USERNAME | ||||||
| String accesskey = System.getenv("LT_ACCESS_KEY") == null ? "YOUR_LT_ACCESSKEY" : System.getenv("LT_ACCESS_KEY"); //Enter your LambdaTest accessKey at the place of YOUR_LT_ACCESSKEY | ||||||
| String app_id = System.getenv("LT_APP_ID") == null ? "lt://proverbial-android" : System.getenv("LT_APP_ID"); //Enter your LambdaTest App ID at the place of lt://proverbial-android | ||||||
| String grid_url = System.getenv("LT_GRID_URL") == null ? "mobile-hub.lambdatest.com" : System.getenv("LT_GRID_URL"); | ||||||
|
|
||||||
| DesiredCapabilities capability = new DesiredCapabilities(); | ||||||
|
|
||||||
| capability.setCapability("platformName", platformName); | ||||||
| capability.setCapability("deviceName", deviceName); | ||||||
| capability.setCapability("platformVersion", platformVersion); | ||||||
| capability.setCapability("build", "LT-appium-java-cucumber"); | ||||||
| capability.setCapability("name", "Android Test"); | ||||||
| capability.setCapability("isRealMobile", true); | ||||||
| capability.setCapability("app", app_id); //Enter the app url here | ||||||
| capability.setCapability("devicelog", true); | ||||||
| capability.setCapability("autoGrantPermissions", true); | ||||||
| capability.setCapability("network", false); | ||||||
| capability.setCapability("video", true); | ||||||
| capability.setCapability("visual", true); | ||||||
|
|
||||||
| String gridURL = "https://" + username + ":" + accesskey + "@" + grid_url + "/wd/hub"; | ||||||
| connection = new RemoteWebDriver(new URL(gridURL), capability); | ||||||
| } | ||||||
|
|
||||||
| @DataProvider | ||||||
| public Object[][] features() { | ||||||
| return testNGCucumberRunner.provideScenarios(); | ||||||
| public void setUp() throws Exception { | ||||||
|
|
||||||
| UiAutomator2Options options = new UiAutomator2Options(); | ||||||
|
|
||||||
| options.setPlatformName("Android"); | ||||||
| options.setDeviceName("Galaxy S21"); | ||||||
| options.setPlatformVersion("13"); | ||||||
| options.setApp("lt://APP10160171061769791489195489"); | ||||||
|
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.
Suggested change
|
||||||
|
|
||||||
| Map<String, Object> ltOptions = new HashMap<>(); | ||||||
| // Ensure these environment variables are set on your machine | ||||||
| ltOptions.put("user", System.getenv("LT_USERNAME")); | ||||||
| ltOptions.put("accessKey", System.getenv("LT_ACCESS_KEY")); | ||||||
|
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. Update the Readme.md as well |
||||||
| ltOptions.put("isRealMobile", true); | ||||||
| ltOptions.put("build", "LT-Appium-Cucumber"); | ||||||
| ltOptions.put("name", "Proverbial App Scenario"); | ||||||
| ltOptions.put("video", true); | ||||||
| ltOptions.put("visual", true); | ||||||
| ltOptions.put("devicelog", true); | ||||||
|
|
||||||
| options.setCapability("lt:options", ltOptions); | ||||||
|
|
||||||
| driver = new RemoteWebDriver( | ||||||
| new URL("https://mobile-hub.lambdatest.com/wd/hub"), | ||||||
| options | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| @AfterClass(alwaysRun = true) | ||||||
| public void tearDownClass() { | ||||||
| testNGCucumberRunner.finish(); | ||||||
| public void tearDown() { | ||||||
| if (driver != null) { | ||||||
| driver.quit(); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
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. what is the use of this? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Feature: Do native app automation | ||
|
|
||
| Scenario: Proverbial App scenario | ||
| Given user is on the App home page |
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.
Why have we removed this one?