-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.java
More file actions
122 lines (101 loc) · 3.57 KB
/
Copy pathProject.java
File metadata and controls
122 lines (101 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package project;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
import pages.*;
import java.time.Duration;
public class project {
WebDriver driver;
WebDriverWait wait;
String uniqueEmail;
String password = "Thippi46@";
HomePage home;
RegisterPage registerPage;
LoginPage loginPage;
ContactPage contactPage;
ProductPage productPage;
@BeforeClass
void setup() {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
wait = new WebDriverWait(driver, Duration.ofSeconds(20));
driver.get("https://practicesoftwaretesting.com/");
home = new HomePage(driver);
registerPage = new RegisterPage(driver);
loginPage = new LoginPage(driver);
contactPage = new ContactPage(driver);
productPage = new ProductPage(driver);
}
// ---------------- Register -----------------
@Test(priority = 1)
void registerUser() {
home.goToSignIn();
home.goToRegister();
uniqueEmail = "radhakrishna" + System.currentTimeMillis() + "@gmail.com";
registerPage.registerUser(
"Radha",
"Krishna",
"2002-08-16",
"BC colony",
"515767",
"Brahmasamudram",
"Andhra Pradesh",
"India",
"9398473184",
uniqueEmail,
password
);
Assert.assertTrue(registerPage.isLoginBoxVisible(), "❌ Registration failed!");
}
// ---------------- Login -----------------
@Test(priority = 2, dependsOnMethods = "registerUser")
void loginUser() {
loginPage.login(uniqueEmail, password);
Assert.assertTrue(home.isMenuDisplayed(), "❌ Login failed!");
}
// ---------------- Change Language -----------------
@Test(priority = 3, dependsOnMethods = "loginUser")
void changeLanguage() {
home.changeLanguage(2); // Example: French
}
// ---------------- Contact Form -----------------
@Test(priority = 4, dependsOnMethods = "loginUser")
void contactForm() {
home.goToContact();
contactPage.fillContactForm(
"Radha",
"Krishna",
"radhakrishna1432@gmail.com",
5,
"Automation testing helps to find defects quickly and efficiently.",
"C:\\Users\\Dell\\Downloads\\G-Thippeswamy-FlowCV-Resume-20250812.pdf"
);
}
// ---------------- Category & Checkout -----------------
@Test(priority = 5, dependsOnMethods = "loginUser")
void addToCartAndCheckout() throws InterruptedException {
// Go to Home
home.goToHome();
// --- First product: Cash on Delivery ---
productPage.selectCategory(); // select first category
}
@AfterClass
void tearDown() {
if (driver != null) {
driver.quit();
}
}
}