-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathAutenthication.java
More file actions
117 lines (94 loc) · 5.38 KB
/
Autenthication.java
File metadata and controls
117 lines (94 loc) · 5.38 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
package pages;
import org.codacy.BasePage;
import org.codacy.Environment;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
import javax.print.DocFlavor;
import java.util.concurrent.TimeUnit;
import static org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;
public class Autenthication extends BasePage {
private static final String NAV_BAR_LOGIN_LINK = "login_link";
private static final String VALIDATE_LOGIN_PAGE = "Welcome_Back_login";
private static final String GOOGLE_BUTTON = "login_google";
private static final String SELECT_USER_NAME = "identifierId";
private static final String NEXT_BTN = "identifierNext";
private static final String SELECT_PASSWORD_TXT = "//*[@type=\"password\"]";
private static final String PASSWORD_NEXT_BTN = "passwordNext";
private static final String BITBUCKET_BTN = "login_bitbucket";
private static final String LOGIN_FORM = "login-form";
private static final String LOG_IN_WITH_GOOGLE = "//*[@class='google-login']";
private static final String GITHUB_BTN = "login_github";
private static final String GITHUB_LOGIN_FORM = "class=\"auth-form-body mt-3\"";
private static final String GITHUB_LOGIN_TXT = "login_field";
private static final String GITHUB_PASSWORD_TXT = "password";
private static final String GITHUB_SUBMIT = "commit";
private static final String SELECT_ACCOUNT = "account-dropdown";
private static final String SIGN_OUT_BTN = "signout-form";
private static final String TESTE = "//*[@class='ANuIbb IdAqtf']";
public Autenthication(RemoteWebDriver driver, Environment env) {
super(driver, env);
}
public void loginwithGoogle()
{
System.out.println("Test Is Starting");
getElementWhenVisible(By.id(NAV_BAR_LOGIN_LINK)).isDisplayed();
getElementWhenVisible(By.id(NAV_BAR_LOGIN_LINK)).click();
// getElementWhenVisible(By.id(VALIDATE_LOGIN_PAGE)).isDisplayed();
getElementWhenVisible(By.id(GOOGLE_BUTTON)).isDisplayed();
getElementWhenVisible(By.id(GOOGLE_BUTTON)).click();
getElementWhenVisible(By.id(SELECT_USER_NAME)).click();
getElementWhenVisible(By.id(SELECT_USER_NAME)).sendKeys(env.username());
getElementWhenVisible(By.id(NEXT_BTN)).click();
getElementWhenVisible(By.xpath(SELECT_PASSWORD_TXT)).isDisplayed();
// elementNotPresent(By.xpath(TESTE));
wait.until(ExpectedConditions.invisibilityOfElementLocated((By.xpath("//*[@class='ANuIbb IdAqtf']"))));
getElementWhenVisible(By.xpath(SELECT_PASSWORD_TXT)).click();
getElementWhenVisible(By.xpath(SELECT_PASSWORD_TXT)).sendKeys(env.password());
getElementWhenVisible(By.id(PASSWORD_NEXT_BTN)).isDisplayed();
//elementNotPresent(By.xpath(ELEMENT1)).
getElementWhenVisible(By.id(PASSWORD_NEXT_BTN)).click();
}
public void loginWithBitbucket() {
getElementWhenVisible(By.id(NAV_BAR_LOGIN_LINK)).isDisplayed();
getElementWhenVisible(By.id(NAV_BAR_LOGIN_LINK)).click();
// getElementWhenVisible(By.id(VALIDATE_LOGIN_PAGE)).isDisplayed();
getElementWhenVisible(By.id(BITBUCKET_BTN)).isDisplayed();
getElementWhenVisible(By.id(BITBUCKET_BTN)).click();
getElementWhenVisible(By.id(LOGIN_FORM)).isDisplayed();
getElementWhenVisible(By.xpath(LOG_IN_WITH_GOOGLE)).click();
getElementWhenVisible(By.id(SELECT_USER_NAME)).click();
getElementWhenVisible(By.id(SELECT_USER_NAME)).sendKeys(env.username());
getElementWhenVisible(By.id(NEXT_BTN)).click();
getElementWhenVisible(By.xpath(SELECT_PASSWORD_TXT)).isDisplayed();
//elementNotPresent(By.xpath(TESTE));
wait.until(ExpectedConditions.invisibilityOfElementLocated((By.xpath("//*[@class='ANuIbb IdAqtf']"))));
getElementWhenVisible(By.xpath(SELECT_PASSWORD_TXT)).click();
getElementWhenVisible(By.xpath(SELECT_PASSWORD_TXT)).sendKeys(env.password());
getElementWhenVisible(By.id(PASSWORD_NEXT_BTN)).isDisplayed();
getElementWhenVisible(By.id(PASSWORD_NEXT_BTN)).click();
}
public void loginWithGithub() {
getElementWhenVisible(By.id(NAV_BAR_LOGIN_LINK)).isDisplayed();
getElementWhenVisible(By.id(NAV_BAR_LOGIN_LINK)).click();
// getElementWhenVisible(By.id(VALIDATE_LOGIN_PAGE)).isDisplayed();
getElementWhenVisible(By.id(GITHUB_BTN)).isDisplayed();
getElementWhenVisible(By.id(GITHUB_BTN)).click();
//getElementWhenVisible(By.xpath(GITHUB_LOGIN_FORM)).isDisplayed();
getElementWhenVisible(By.id(GITHUB_LOGIN_TXT)).isDisplayed();
getElementWhenVisible(By.id(GITHUB_LOGIN_TXT)).click();
getElementWhenVisible(By.id(GITHUB_LOGIN_TXT)).sendKeys(env.username());
getElementWhenVisible(By.id(GITHUB_PASSWORD_TXT)).isDisplayed();
getElementWhenVisible(By.id(GITHUB_PASSWORD_TXT)).click();
getElementWhenVisible(By.id(GITHUB_PASSWORD_TXT)).sendKeys(env.password());
getElementWhenVisible(By.name(GITHUB_SUBMIT)).click();
}
public void logout()
{
getElementWhenVisible(By.id(SELECT_ACCOUNT)).click();
getElementWhenVisible(By.id(SIGN_OUT_BTN)).click();
}
}