Skip to content

Commit 785896c

Browse files
Add : [Logout Feature]
message : 1. Add logout feature test 2. Update report 3. Update README.md
1 parent cc43f9b commit 785896c

File tree

12 files changed

+253
-2
lines changed

12 files changed

+253
-2
lines changed

README.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# 🚀 QA Automation with Selenium Java and Cucumber 🥒
1+
# 🥒 QA Automation with Selenium Java and Cucumber
22

3-
### JDK Version
3+
### 🚀 JDK Version
44

55
JDK : 20
66

@@ -148,4 +148,64 @@ Feature: Checkout
148148
| example | example_last_name | 3301 |
149149
| --- | example_last_name | 3301 |
150150
| ? | --- | 0 |
151+
152+
Scenario: User Failed checks Out Products
153+
Given The user is on the cart page
154+
Then The user should see at least 2 products in their cart
155+
And The user clicks the checkout button
156+
And The user should be redirected to the checkout page step "one"
157+
And The user clicks the continue button
158+
Then The user should be see error message
159+
160+
Scenario: User Failed checks Out Products without first name
161+
Given The user is on the cart page
162+
Then The user should see at least 2 products in their cart
163+
And The user clicks the checkout button
164+
And The user should be redirected to the checkout page step "one"
165+
And The user enters "example_last_name" as the last name
166+
And The user enters 111 as the postal code
167+
And The user clicks the continue button
168+
Then The user should be see error message
169+
170+
Scenario: User Failed checks Out Products without last name
171+
Given The user is on the cart page
172+
Then The user should see at least 2 products in their cart
173+
And The user clicks the checkout button
174+
And The user should be redirected to the checkout page step "one"
175+
And The user enters "example" as the first name
176+
And The user enters 111 as the postal code
177+
And The user clicks the continue button
178+
Then The user should be see error message
179+
180+
Scenario: User Failed checks Out Products without postal code
181+
Given The user is on the cart page
182+
Then The user should see at least 2 products in their cart
183+
And The user clicks the checkout button
184+
And The user should be redirected to the checkout page step "one"
185+
And The user enters "example" as the first name
186+
And The user enters "example_last_name" as the last name
187+
And The user clicks the continue button
188+
Then The user should be see error message
151189
```
190+
191+
#### Logout
192+
193+
![](report/Logout.png)
194+
195+
```gherkin
196+
Feature: Logout
197+
198+
Background:
199+
Given The user opens the web page or app
200+
When The user enters a valid username
201+
And The user enters a valid password
202+
And The user clicks the login button
203+
204+
Scenario: User logout after login
205+
Given The user should be logged in successfully
206+
When The user clicks the burger button
207+
Then The user should see the slide menu
208+
And The user clicks logout
209+
Then The user should be redirected to the login page
210+
211+
```

report/AddToCart.png

12.1 KB
Loading

report/Cart.png

11.2 KB
Loading

report/Checkout.png

261 KB
Loading

report/Login.png

13.9 KB
Loading

report/Logout.png

193 KB
Loading

report/ReportTesting.html

Lines changed: 50 additions & 0 deletions
Large diffs are not rendered by default.

src/test/java/config/elements/ElementInventory.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,16 @@ public WebElement shoppingCart() {
3030
public String sh() {
3131
return this.webDriver.findElement(By.id("shopping_cart_container")).getText();
3232
}
33+
34+
public WebElement burgerButton() {
35+
return this.webDriver.findElement(By.id("react-burger-menu-btn"));
36+
}
37+
38+
public WebElement slideMenu() {
39+
return this.webDriver.findElement(By.className("bm-menu-wrap"));
40+
}
41+
42+
public WebElement logout() {
43+
return this.webDriver.findElement(By.id("logout_sidebar_link"));
44+
}
3345
}

src/test/java/main/Logout.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package main;
2+
3+
import config.Config;
4+
import config.SetupDriver;
5+
import config.elements.ElementInventory;
6+
import org.junit.jupiter.api.Assertions;
7+
import org.openqa.selenium.WebElement;
8+
9+
import java.time.Duration;
10+
11+
public class Logout {
12+
private final SetupDriver setupDriver;
13+
private final Config config;
14+
private final ElementInventory elementInventory;
15+
16+
public Logout(SetupDriver setupDriver) {
17+
this.setupDriver = setupDriver;
18+
this.config = this.setupDriver.getConfig();
19+
this.elementInventory = new ElementInventory(this.setupDriver.getWebDriver());
20+
}
21+
22+
public void userClicksBurgerButton() {
23+
WebElement burgerButton = this.elementInventory.burgerButton();
24+
burgerButton.click();
25+
}
26+
27+
public void userShouldSeeSlideMenu() {
28+
WebElement slideMenu = this.elementInventory.slideMenu();
29+
Assertions.assertTrue(slideMenu.isDisplayed());
30+
}
31+
32+
public void userClicksLogout() {
33+
this.setupDriver.getWebDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(2));
34+
WebElement logout = this.elementInventory.logout();
35+
logout.click();
36+
}
37+
38+
public void userShouldBeRedirectedToLoginPage() {
39+
String currentUrl = this.setupDriver.getCurrentUrl();
40+
Assertions.assertEquals(this.config.getBaseUrl(), currentUrl);
41+
}
42+
}

src/test/java/resources/features/checkout.feature

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,41 @@ Feature: Checkout
3030
| example | example_last_name | 3301 |
3131
| --- | example_last_name | 3301 |
3232
| ? | --- | 0 |
33+
34+
Scenario: User Failed checks Out Products
35+
Given The user is on the cart page
36+
Then The user should see at least 2 products in their cart
37+
And The user clicks the checkout button
38+
And The user should be redirected to the checkout page step "one"
39+
And The user clicks the continue button
40+
Then The user should be see error message
41+
42+
Scenario: User Failed checks Out Products without first name
43+
Given The user is on the cart page
44+
Then The user should see at least 2 products in their cart
45+
And The user clicks the checkout button
46+
And The user should be redirected to the checkout page step "one"
47+
And The user enters "example_last_name" as the last name
48+
And The user enters 111 as the postal code
49+
And The user clicks the continue button
50+
Then The user should be see error message
51+
52+
Scenario: User Failed checks Out Products without last name
53+
Given The user is on the cart page
54+
Then The user should see at least 2 products in their cart
55+
And The user clicks the checkout button
56+
And The user should be redirected to the checkout page step "one"
57+
And The user enters "example" as the first name
58+
And The user enters 111 as the postal code
59+
And The user clicks the continue button
60+
Then The user should be see error message
61+
62+
Scenario: User Failed checks Out Products without postal code
63+
Given The user is on the cart page
64+
Then The user should see at least 2 products in their cart
65+
And The user clicks the checkout button
66+
And The user should be redirected to the checkout page step "one"
67+
And The user enters "example" as the first name
68+
And The user enters "example_last_name" as the last name
69+
And The user clicks the continue button
70+
Then The user should be see error message

0 commit comments

Comments
 (0)