Skip to content

Commit b5b6999

Browse files
Finish : [Done All Testing - 1]
1 parent eba656d commit b5b6999

File tree

17 files changed

+312
-63
lines changed

17 files changed

+312
-63
lines changed

README.md

Lines changed: 93 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,58 +25,126 @@ https://www.saucedemo.com/
2525

2626
2. Users
2727

28-
| Username | Password |
29-
|-----------------|--------------|
30-
| standard_user | secret_sauce |
31-
| locked_out_user | secret_sauce |
32-
| problem_user | secret_sauce |
33-
| error_user | secret_sauce |
28+
| Username | Password |
29+
|---------------|---------------|
30+
| standard_user | secret_sauce |
31+
| fake_user | fake_password |
3432

3533
### Report
3634

3735
#### Login Feature
3836

39-
![](/home/celvine/Downloads/code/Tugas_06_CelvineAdiPutra/report/LoginReport.png)
37+
![](/home/celvine/Downloads/code/Tugas_06_CelvineAdiPutra/report/Login.png)
4038

4139
```gherkin
4240
Feature: Login feature
4341
44-
Scenario Outline: User successfully logs in with valid credentials
42+
Background:
4543
Given The user opens the web page or app
46-
When The user enters <username> as username
47-
And The user enters <password> as password
44+
45+
Scenario: User successfully logs in with valid credentials
46+
When The user enters a valid username
47+
And The user enters a valid password
4848
And The user clicks the login button
4949
Then The user should be logged in successfully
50-
Examples:
51-
| username | password |
52-
| standard_user | secret_sauce |
5350
54-
Scenario Outline: User fails to log in with invalid credentials
55-
Given The user opens the web page or app
56-
When The user enters <username> as username
57-
And The user enters <password> as password
51+
Scenario: User failed logs in with invalid password with registered user credentials
52+
When The user enters a valid username
53+
And The user enters a invalid password
5854
And The user clicks the login button
59-
Then The user should see an authentication error message
60-
Examples:
61-
| username | password |
62-
| example | 123 |
55+
Then The user should be see error message
56+
57+
Scenario: User failed logs in with invalid credentials
58+
When The user enters a invalid username
59+
And The user enters a invalid password
60+
And The user clicks the login button
61+
Then The user should be see error message
6362
```
6463

65-
#### Add to Cart
64+
#### Add Product to Cart
6665

67-
![](/home/celvine/Downloads/code/Tugas_06_CelvineAdiPutra/report/AddToCartReport.png)
66+
![](/home/celvine/Downloads/code/Tugas_06_CelvineAdiPutra/report/AddToCart.png)
6867

6968
```gherkin
7069
Feature: Add Product to Cart
7170
7271
Background:
73-
Given The user is logged in
72+
Given The user opens the web page or app
73+
When The user enters a valid username
74+
And The user enters a valid password
75+
And The user clicks the login button
76+
Then The user should be logged in successfully
7477
7578
Scenario: User successfully adds a product to the cart
7679
When The user clicks the add to cart button
7780
Then The text on the add to cart button should change to remove
7881
Then The number of items in the cart icon should be 1
79-
When The user click the add to cart button other product
82+
When The user clicks the add to cart button for another product
8083
Then The text on the add to cart button other product should change to remove
8184
Then The number of items in the cart icon should be 2
85+
```
86+
87+
#### Cart
88+
89+
![](/home/celvine/Downloads/code/Tugas_06_CelvineAdiPutra/report/Cart.png)
90+
91+
```gherkin
92+
Feature: Remove Items from Cart
93+
94+
Background:
95+
Given The user opens the web page or app
96+
When The user enters a valid username
97+
And The user enters a valid password
98+
And The user clicks the login button
99+
Then The user should be logged in successfully
100+
Then The user clicks the add to cart button
101+
Then The user clicks the add to cart button for another product
102+
103+
Scenario: Remove an Item from the Cart
104+
Given The user is on the cart page
105+
Then The user should see at least 2 products in their cart
106+
When The user clicks the remove button for the first item
107+
Then The number of items in the cart icon should be 1
108+
Then The user should see at least 1 products in their cart
109+
When The user clicks the remove button for the first item
110+
Then The shopping cart should be empty
111+
```
112+
113+
#### Checkout
114+
115+
![](/home/celvine/Downloads/code/Tugas_06_CelvineAdiPutra/report/Checkout.png)
116+
117+
```gherkin
118+
Feature: Checkout
119+
120+
Background:
121+
Given The user opens the web page or app
122+
When The user enters a valid username
123+
And The user enters a valid password
124+
And The user clicks the login button
125+
Then The user should be logged in successfully
126+
And The user clicks the add to cart button
127+
And The user clicks the add to cart button for another product
128+
And The user is on the cart page
129+
130+
Scenario Outline: User Successfully Checks Out Products
131+
Given The user is on the cart page
132+
Then The user should see at least 2 products in their cart
133+
And The user clicks the checkout button
134+
And The user should be redirected to the checkout page step "one"
135+
And The user enters <fistName> as the first name
136+
And The user enters <lastName> as the last name
137+
And The user enters <postalCode> as the postal code
138+
And The user clicks the continue button
139+
And The user should be redirected to the checkout page step "two"
140+
And The user clicks the finish button
141+
And The user should be redirected to the checkout complete page
142+
And The user clicks the back home button
143+
Then The number of items in the cart icon should be empty
144+
145+
Examples:
146+
| fistName | lastName | postalCode |
147+
| example | example_last_name | 3301 |
148+
| --- | example_last_name | 3301 |
149+
| ? | --- | 0 |
82150
```

report/AddToCart.png

206 KB
Loading

report/AddToCartReport.png

-98.4 KB
Binary file not shown.

report/Cart.png

219 KB
Loading

report/Checkout.png

287 KB
Loading

report/Login.png

228 KB
Loading

report/LoginReport.png

-131 KB
Binary file not shown.

src/test/java/config/elements/ElementFormCart.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,8 @@ public void remove() {
4949
this.getItemName();
5050
this.webDriver.findElement(By.id("remove-" + this.productName)).click();
5151
}
52+
53+
public WebElement checkoutButton() {
54+
return this.cartList.findElement(By.id("checkout"));
55+
}
5256
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package config.elements;
2+
3+
import org.openqa.selenium.By;
4+
import org.openqa.selenium.WebDriver;
5+
6+
public class ElementFormCheckout {
7+
private final WebDriver webDriver;
8+
9+
public ElementFormCheckout(WebDriver webDriver) {
10+
this.webDriver = webDriver;
11+
}
12+
13+
public void typeField(String id, String value) {
14+
this.webDriver.findElement(By.id(id)).sendKeys(value);
15+
}
16+
17+
public void clickNextButton(String id) {
18+
this.webDriver.findElement(By.id(id)).click();
19+
}
20+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ public WebElement buttonRemoveFromCart(String productName) {
2626
public WebElement shoppingCart() {
2727
return this.webDriver.findElement(By.cssSelector(".shopping_cart_link > .shopping_cart_badge"));
2828
}
29+
30+
public String sh() {
31+
return this.webDriver.findElement(By.id("shopping_cart_container")).getText();
32+
}
2933
}

0 commit comments

Comments
 (0)