Created
May 18, 2016 03:18
-
-
Save nhatthuyld/a93e45f9edabe1def8f2b5d7a3e92d7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.examples.seleniumrc; | |
import org.junit.After; | |
import org.junit.Assert; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.openqa.selenium.Alert; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.By.ByXPath; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
public class KyotokimonoRentalTest { | |
WebDriver driver; | |
@Before | |
public void setUp() throws Exception { | |
System.setProperty("webdriver.chrome.driver", "D:\\DEV\\chromedriver.exe"); | |
driver = new ChromeDriver(); | |
driver.manage().window().maximize(); | |
driver.get("https://kyotokimono-rental.com/reserve"); | |
} | |
@After | |
public void tearDown() throws Exception { | |
//driver.quit(); | |
} | |
@Test | |
public void fisrtSelectBox() throws InterruptedException { | |
WebElement checkBoxElement = driver.findElement(By.id("list_plans_1SelectBoxItContainer")); | |
checkBoxElement.click(); | |
Thread.sleep(500); | |
//click next button | |
driver.findElement(By.xpath(".//*[@id='formAddPlan']/div[1]/div/ul/li[1]/div[3]/div[2]/div[1]/a")).click(); | |
Thread.sleep(500); | |
//throw alert | |
Alert alert = driver.switchTo().alert(); | |
alert.getText(); | |
System.out.println(alert.getText()); | |
alert.accept(); | |
Thread.sleep(500); | |
//select 3 people | |
WebElement itemElement3 = driver | |
.findElement(By.xpath(".//*[@id='list_plans_1SelectBoxItOptions']/li[4]/a/span[2]")); | |
itemElement3.click(); | |
Thread.sleep(500); | |
//click next button | |
driver.findElement(By.xpath(".//*[@id='formAddPlan']/div[1]/div/ul/li[1]/div[3]/div[2]/div[1]/a")).click(); | |
Thread.sleep(500); | |
} | |
@Test | |
public void alertMessage() throws InterruptedException { | |
WebElement checkBoxElement = driver.findElement(By.id("list_plans_1SelectBoxItContainer")); | |
checkBoxElement.click(); | |
Thread.sleep(500); | |
//click next button | |
driver.findElement(By.xpath(".//*[@id='formAddPlan']/div[1]/div/ul/li[1]/div[3]/div[2]/div[1]/a")).click(); | |
Thread.sleep(500); | |
// throw alert | |
Alert alert = driver.switchTo().alert(); | |
alert.getText(); | |
System.out.println(alert.getText()); | |
alert.accept(); | |
Thread.sleep(500); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment