Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SignInTest.java #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 45 additions & 14 deletions src/main/java/SignInTest.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
import com.sun.javafx.PlatformUtil;
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;

public class SignInTest {
import com.sun.javafx.PlatformUtil;

WebDriver driver = new ChromeDriver();
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() {

setDriverPath();

driver.get("https://www.cleartrip.com/");
waitFor(2000);

driver.findElement(By.linkText("Your trips")).click();
driver.findElement(By.id("SignIn")).click();
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();

String errors1 = driver.findElement(By.id("errors1")).getText();
//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.quit();

driver.switchTo().parentFrame();
}

@AfterTest
public void afterTest()
{
driver.close();
driver.quit();
}

private void waitFor(int durationInMilliSeconds) {
Expand All @@ -35,7 +65,8 @@ private void waitFor(int durationInMilliSeconds) {
}
}

private void setDriverPath() {
@SuppressWarnings("restriction")
private void setDriverPath() {
if (PlatformUtil.isMac()) {
System.setProperty("webdriver.chrome.driver", "chromedriver");
}
Expand Down