-
Notifications
You must be signed in to change notification settings - Fork 572
Expand file tree
/
Copy pathSignInTest.java
More file actions
82 lines (66 loc) · 2.49 KB
/
SignInTest.java
File metadata and controls
82 lines (66 loc) · 2.49 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
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.sun.javafx.PlatformUtil;
public class SignInTest {
WebDriver driver ;
SignInTestElements sine;
@BeforeTest
public void beforeTest() {
setDriverPath();
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");
driver = new ChromeDriver(options);
sine = new SignInTestElements(driver);
}
@Test
public void shouldThrowAnErrorIfSignInDetailsAreMissing() {
driver.get("https://www.cleartrip.com/");
driver.manage().window().fullscreen();
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// waitFor(2000);
//driver.findElement(By.linkText("Your trips")).click();
sine.yourTripsElement().click();
//driver.findElement(By.id("SignIn")).click();
sine.signInElement().click();
//driver.findElement(By.id("signInButton")).click();
driver.switchTo().frame(sine.iFrameElement());
sine.signInButtonElement().click();
String errors1 = sine.errorMsgElement().getText();
Assert.assertTrue(errors1.contains("There were errors in your submission"));
driver.switchTo().parentFrame();
}
@AfterTest
public void afterTest()
{
driver.close();
driver.quit();
}
private void waitFor(int durationInMilliSeconds) {
try {
Thread.sleep(durationInMilliSeconds);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
@SuppressWarnings("restriction")
private void setDriverPath() {
if (PlatformUtil.isMac()) {
System.setProperty("webdriver.chrome.driver", "chromedriver");
}
if (PlatformUtil.isWindows()) {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
}
if (PlatformUtil.isLinux()) {
System.setProperty("webdriver.chrome.driver", "chromedriver_linux");
}
}
}