Skip to content

Commit

Permalink
real mobile changes
Browse files Browse the repository at this point in the history
  • Loading branch information
4DvAnCeBoY committed Aug 3, 2021
1 parent d7d8225 commit 5744d91
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mobile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="1" parallel="tests" name="Suite">
<test thread-count="1" parallel="classes" name="Test">
<classes>
<class name="com.lambdatest.TestNGTodoMobile"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
106 changes: 106 additions & 0 deletions src/test/java/com/lambdatest/TestNGTodoMobile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.lambdatest;

import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.ITestContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class TestNGTodoMobile {

private RemoteWebDriver driver;
private String Status = "failed";

@BeforeMethod
public void setup(Method m, ITestContext ctx) throws MalformedURLException {
String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME");
String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY");
;
String hub = "@hub.lambdatest.com/wd/hub";

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Google Pixel 4a");
caps.setCapability("build", "TestNG With Java");
caps.setCapability("name", m.getName() + this.getClass().getName());
caps.setCapability("plugin", "git-testng");
caps.setCapability("isRealMobile", true);

String[] Tags = new String[] { "Feature", "Tag", "Moderate" };
caps.setCapability("tags", Tags);

driver = new RemoteWebDriver(new URL("https://" + username + ":" + authkey + hub), caps);
}

@Test
public void basicTest() throws InterruptedException {
String spanText;
System.out.println("Loading Url");
Thread.sleep(100);
driver.get("https://lambdatest.github.io/sample-todo-app/");

System.out.println("Checking Box");
driver.findElement(By.name("li1")).click();

System.out.println("Checking Another Box");
driver.findElement(By.name("li2")).click();

System.out.println("Checking Box");
driver.findElement(By.name("li3")).click();

System.out.println("Checking Another Box");
driver.findElement(By.name("li4")).click();

driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6");
driver.findElement(By.id("addbutton")).click();

driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7");
driver.findElement(By.id("addbutton")).click();

driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8");
driver.findElement(By.id("addbutton")).click();

System.out.println("Checking Another Box");
driver.findElement(By.name("li1")).click();

System.out.println("Checking Another Box");
driver.findElement(By.name("li3")).click();

System.out.println("Checking Another Box");
driver.findElement(By.name("li7")).click();

System.out.println("Checking Another Box");
driver.findElement(By.name("li8")).click();

System.out.println("Entering Text");
driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It");

driver.findElement(By.id("addbutton")).click();

System.out.println("Checking Another Box");
driver.findElement(By.name("li9")).click();

// Let's also assert that the todo we added is present in the list.

spanText = driver.findElementByXPath("/html/body/div/div/div/ul/li[9]/span").getText();
Assert.assertEquals("Get Taste of Lambda and Stick to It", spanText);
Status = "passed";
Thread.sleep(800);

System.out.println("TestFinished");

}

@AfterMethod
public void tearDown() {
driver.executeScript("lambda-status=" + Status);
driver.quit();
}

}

0 comments on commit 5744d91

Please sign in to comment.