forked from getgauge-examples/java-maven-selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogOut.java
More file actions
44 lines (36 loc) · 1.27 KB
/
Copy pathLogOut.java
File metadata and controls
44 lines (36 loc) · 1.27 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
import com.thoughtworks.gauge.Step;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import utils.driver.Driver;
import static org.junit.Assert.assertTrue;
public class LogOut {
private static By submitLogOut = By.linkText("Log out");
@Step("Log out the customer")
public void logOutTheCustomer() {
logOut();
}
@Step("Clear previous login")
public void clearPreviousLogin() {
try {
logOut();
} catch (Exception ex) {
System.out.println("no previously logged in Customers");
}
}
@Step("Give an option to Log Out")
public void giveAnOptionToLogOut() {
WebDriver webDriver = Driver.webDriver;
WebElement logOut = webDriver.findElement(submitLogOut);
assertTrue(logOut.isDisplayed());
}
private void logOut() {
WebDriver webDriver = Driver.webDriver;
WebDriverWait wait = new WebDriverWait(webDriver, 5);
wait.until(ExpectedConditions.visibilityOfElementLocated(submitLogOut));
WebElement logOut = webDriver.findElement(submitLogOut);
logOut.click();
}
}