|
1 | 1 | package com.lambdatest;
|
2 | 2 |
|
| 3 | +import Utills.UtilsMethods; |
3 | 4 | import org.openqa.selenium.By;
|
| 5 | +import org.openqa.selenium.Keys; |
4 | 6 | import org.openqa.selenium.remote.DesiredCapabilities;
|
5 | 7 | import org.openqa.selenium.remote.RemoteWebDriver;
|
6 |
| -import org.openqa.selenium.support.ui.ExpectedConditions; |
7 |
| -import org.openqa.selenium.support.ui.WebDriverWait; |
| 8 | +import org.openqa.selenium.support.ui.Select; |
8 | 9 | import org.testng.Assert;
|
9 | 10 | import org.testng.ITestContext;
|
10 | 11 | import org.testng.annotations.AfterMethod;
|
|
15 | 16 | import java.net.MalformedURLException;
|
16 | 17 | import java.net.URL;
|
17 | 18 |
|
18 |
| -public class SampleAutomation { |
19 |
| - |
| 19 | +public class RegisterAccount { |
20 | 20 | private RemoteWebDriver driver;
|
| 21 | + UtilsMethods methods = new UtilsMethods(); |
21 | 22 | private String Status = "failed";
|
22 | 23 |
|
23 | 24 | @BeforeMethod
|
24 | 25 | public void setup(Method m, ITestContext ctx) throws MalformedURLException {
|
25 |
| -// String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); |
| 26 | + // String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); |
26 | 27 | String username = System.getProperty("LT_USERNAME");
|
27 |
| -// String authKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); |
| 28 | + // String authKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); |
28 | 29 | String authKey = System.getProperty("LT_ACCESS_KEY");
|
29 |
| - |
30 | 30 | String hub = "@hub.lambdatest.com/wd/hub";
|
31 |
| - |
32 | 31 | DesiredCapabilities caps = new DesiredCapabilities();
|
33 | 32 | caps.setCapability("platform", "win10");
|
34 | 33 | caps.setCapability("browserName", "chrome");
|
35 | 34 | caps.setCapability("version", "latest");
|
36 | 35 | caps.setCapability("build", System.getProperty("Build_Name") == null ? m.getName() + " - " + this.getClass().getName() : System.getProperty("Build_Name"));
|
37 | 36 | caps.setCapability("name", m.getName() + " - " + this.getClass().getName());
|
38 | 37 | caps.setCapability("plugin", "git-testng");
|
39 |
| - |
40 | 38 | String[] Tags = new String[] { "Feature", "Falcon", "Severe" };
|
41 | 39 | caps.setCapability("tags", Tags);
|
42 |
| - |
43 | 40 | driver = new RemoteWebDriver(new URL("https://" + username + ":" + authKey + hub), caps);
|
44 |
| - |
45 |
| - } |
46 |
| - public void wait(By locator, int waitTime) { |
47 |
| - WebDriverWait wait = new WebDriverWait(driver, waitTime); |
48 |
| - wait.until(ExpectedConditions.presenceOfElementLocated(locator)); |
49 | 41 | }
|
50 | 42 |
|
51 | 43 | @Test(priority = 1)
|
52 | 44 | public void register() {
|
53 | 45 | driver.get("https://ecommerce-playground.lambdatest.io/");
|
54 | 46 | driver.findElement(By.cssSelector("#main-navigation a[href*='account/account']")).click();
|
55 | 47 | driver.findElement(By.cssSelector("#column-right a[href*='account/register']")).click();
|
56 |
| - wait(By.id("input-firstname"), 30); |
| 48 | + methods.wait(driver, By.id("input-firstname"), 30); |
57 | 49 | driver.findElement(By.id("input-firstname")).sendKeys("name");
|
58 | 50 | driver.findElement(By.id("input-lastname")).sendKeys("LastName");
|
59 | 51 | driver.findElement(By.id("input-email")).sendKeys("Email");
|
60 | 52 | driver.findElement(By.id("input-telephone")).sendKeys("Number");
|
61 | 53 | driver.findElement(By.id("input-password")).sendKeys("Password");
|
62 | 54 | driver.findElement(By.id("input-confirm")).sendKeys("Confirm password");
|
63 |
| -// driver.findElement(By.id("input-agree")).click(); |
| 55 | + // driver.findElement(By.id("input-agree")).click(); |
64 | 56 | driver.findElement(By.cssSelector("input[type='submit']")).click();
|
65 | 57 | System.out.println("TestFinished");
|
66 | 58 | }
|
67 | 59 |
|
68 |
| -// @Test(priority = 2) |
69 |
| - public void searchProduct() { |
70 |
| - driver.findElement(By.cssSelector("#main-header [placeholder='Search For Products']")).sendKeys("i pod Nano"); |
71 |
| - driver.findElement(By.cssSelector("#search .dropdown ul>li:first-of-type")).click(); |
72 |
| - driver.findElement(By.cssSelector(".order-1 .btn-cart")).click(); |
73 |
| - } |
74 |
| - |
75 | 60 | @AfterMethod
|
76 | 61 | public void tearDown() {
|
77 | 62 | driver.executeScript("lambda-status=" + Status);
|
|
0 commit comments