-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login_Tests.txt
65 lines (49 loc) · 1.64 KB
/
Login_Tests.txt
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
package stepDefinition;
import static org.junit.Assert.assertEquals;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import junit.framework.Assert;
import myLibrary.Constants;
import pages.Login_page;
import utility.BaseUtil;
public class Login_Tests extends BaseUtil {
private BaseUtil base;
public Login_Tests(BaseUtil base) {
this.base = base;
}
//Scenario: User to be able to login with correct user name and password
@Given("user opens url")
public void user_open_url() {
base.driver.get(Constants.URL);
}
@When ("user enters valid username")
public void user_enters_valid_username() {
Login_page login = new Login_page(base);
login.enterUsername("standard_user");
}
@And ("user enters valid password")
public void user_enters_valid_password() {
Login_page login = new Login_page(base);
login.enterPassword("secret_sauce");
}
@Then ("user clicks on login button")
public void user_clicks_on_login_button() {
Login_page login = new Login_page(base);
login.clickOnLoginButton();
}
@And ("user see homepage")
public void user_see_homepage() {
Login_page login = new Login_page(base);
String actualURL = base.driver.getCurrentUrl();
String expectedURL = Constants.HOMEPAGE_URL;
assertEquals(actualURL, expectedURL);
}
@Given ("user logs in as a locked user")
public void user_logs_in_as_a_locked_user() {
base.driver.get(Constants.URL);
Login_page login = new Login_page(base);
login.loginTowebsite("standard_user", "secret_sauce");
}
}