-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoginAutomated
189 lines (162 loc) · 5.65 KB
/
LoginAutomated
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package Login;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.Color;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class LoginA
{
public static WebDriver LoginDriver;
public static String URL = " URL";
public static String Email= "Andriowats23on@gmail.com";
public static String EmailNotVerified = "Andriowatson1@gmail.com";
public static String Password1 = "";
public static String Password = "";
public static String ValidEmail = "";
public static String ValidPassword = "";
public static String CSSColor = "#d50000";
@BeforeTest
public void BeforeTest ()
{
System.setProperty("webdriver.gecko.driver", "D:\\Aazad\\Selenium\\geckodriver\\geckodriver.exe");
LoginDriver = new FirefoxDriver();
LoginDriver.manage().window().maximize();
}
@Test (priority=0)
public void BlankField()
{
LoginDriver.get(URL);
LoginDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
LoginJAR.LoginPage(LoginDriver).click();
System.out.println("");
System.out.println("Script Number 1: BlankField");
LoginJAR.EmailID(LoginDriver).click();
LoginJAR.EmailID(LoginDriver).clear();
LoginJAR.Password(LoginDriver).click();
String Email= LoginJAR.EmailID(LoginDriver).getCssValue("caret-color");
//System.out.println(Firtnamecolor);
String Emailhex = Color.fromString(Email).asHex();
System.out.println("Validation Color code: "+Emailhex);
if(Emailhex.contentEquals(CSSColor))
{
System.out.println("Please Enter Email-ID");
}
else
{
System.out.println("");
System.err.println("E-Mail Field is failed to Indicate Red Color");
System.out.println("");
}
LoginJAR.Password(LoginDriver).click();
LoginJAR.EmailID(LoginDriver).clear();
LoginJAR.LoginButton(LoginDriver).click();
String Passwordcolor= LoginJAR.Password(LoginDriver).getCssValue("caret-color");
//System.out.println(Firtnamecolor);
String Passwordhex = Color.fromString(Passwordcolor).asHex();
System.out.println("Validation Color code: "+Passwordhex);
if(Passwordhex.contentEquals(CSSColor))
{
System.out.println("Please Enter Password");
}
else
{
System.out.println("");
System.err.println("Password Field is failed to Indicate Red Color");
System.out.println("");
}
}
@Test(priority=1)
public void EmailNotVerfied()
{
((JavascriptExecutor)LoginDriver).executeScript("window.open('about:blank', '-blank')");
// To switch to the new tab
ArrayList<String> tabs = new ArrayList<String>(LoginDriver.getWindowHandles());
LoginDriver.switchTo().window(tabs.get(1));
LoginDriver.get(URL);
LoginDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
LoginJAR.LoginPage(LoginDriver).click();
System.out.println("");
System.out.println("Script Number 2: EmailNotVerified");
System.out.println("");
LoginJAR.EmailID(LoginDriver).sendKeys(EmailNotVerified);
LoginJAR.Password(LoginDriver).sendKeys(Password1);
LoginJAR.LoginButton(LoginDriver).click();
if(LoginJAR.FinalMessage1(LoginDriver).isDisplayed())
{
String Message = LoginJAR.FinalMessage(LoginDriver);
System.err.println(Message);
System.out.println("");
}
else
{
System.out.println("Failed to show the message of E-Mail not Verfied");
}
}
@Test (priority=2)
public void InvalidCredential()
{
((JavascriptExecutor)LoginDriver).executeScript("window.open('about:blank', '+blank')");
// To switch to the new tab
ArrayList<String> tabs = new ArrayList<String>(LoginDriver.getWindowHandles());
LoginDriver.switchTo().window(tabs.get(2));
LoginDriver.get(URL);
LoginDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
LoginJAR.LoginPage(LoginDriver).click();
System.out.println("");
System.out.println("Script Number 3: InvalidCredential");
System.out.println("");
LoginJAR.EmailID(LoginDriver).sendKeys(Email);
LoginJAR.Password(LoginDriver).sendKeys(Password);
LoginJAR.LoginButton(LoginDriver).click();
if(LoginJAR.FinalMessage1(LoginDriver).isDisplayed())
{
System.out.println("");
System.err.println(LoginJAR.FinalMessage(LoginDriver));
System.out.println("");
}
else
{
System.out.println();
System.err.println("Failed to show Message");
}
}
@Test (priority=3)
public void ValidCredential()
{
((JavascriptExecutor)LoginDriver).executeScript("window.open('about:blank', '+blank')");
// To switch to the new tab
ArrayList<String> tabs = new ArrayList<String>(LoginDriver.getWindowHandles());
LoginDriver.switchTo().window(tabs.get(1));
LoginDriver.get(URL);
LoginDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
LoginJAR.LoginPage(LoginDriver).click();
System.out.println("");
System.out.println("Script Number 4: ValidCredential");
System.out.println("");
LoginJAR.EmailID(LoginDriver).sendKeys(ValidEmail);
LoginJAR.Password(LoginDriver).sendKeys(ValidPassword);
LoginJAR.LoginButton(LoginDriver).click();
if(LoginJAR.FinalMessage1(LoginDriver).isDisplayed())
{
System.out.println("");
System.err.println(LoginJAR.FinalMessage(LoginDriver));
System.out.println("");
}
else
{
System.out.println();
System.err.println("Failed to show Message");
}
}
@AfterTest
public void CloseBrowser() throws Exception
{
Thread.sleep(5000);
LoginDriver.quit();
}
}