Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class OrderTest {
- private WebDriver driver;
- private String baseUrl;
- private StringBuffer verificationErrors = new StringBuffer();
- @Before
- public void SetUp() throws Exception {
- System.setProperty("webdriver.gecko.driver", "C:\Users\egor\Documents\geckodriver.exe");
- driver = new FirefoxDriver();
- baseUrl = "https://www.natalie-tours.ru";
- }
- @Test
- public void TestOrder() throws Exception{
- this.driver.get(baseUrl);
- this.driver.manage().window().maximize();
- WebElement countries = this.driver.findElement(By.id("countries"));
- countries.click();
- Select dropdownCountry = new Select(countries);
- dropdownCountry.selectByValue("18");
- WebElement myChosenCountry = dropdownCountry.getFirstSelectedOption();
- myChosenCountry.sendKeys(Keys.ENTER);
- String parentHandle = this.driver.getWindowHandle();
- WebElement selectZone = this.driver.findElement(By.id("zones"));
- selectZone.click();
- Select dropdownZone = new Select((selectZone));
- dropdownZone.selectByValue("16");
- WebElement myChosenZone = dropdownZone.getFirstSelectedOption();
- myChosenZone.sendKeys(Keys.ENTER);
- WebElement searchButton = this.driver.findElement(By.cssSelector("input[type="submit"]"));
- searchButton.click();
- Thread.sleep(10000);
- Set<String> windows = this.driver.getWindowHandles();
- System.out.println(windows.size());
- Iterator iterator = windows.iterator();
- String currentWindowId;
- while (iterator.hasNext()){
- currentWindowId = iterator.next().toString();
- if (!currentWindowId.equals(parentHandle)){
- this.driver.switchTo().window(currentWindowId);
- WebElement buttonOpt = this.driver.findElement(By.xpath("//*[@id="moreInfo1293951883"]/button/span"));
- buttonOpt.click();
- }
- }
- Thread.sleep(10000);
- }
- private boolean isElementPresent(By by) {
- try {
- driver.findElement(by);
- return true;
- } catch (NoSuchElementException e) {
- return false;
- }
- }
- private boolean isAlertPresent() {
- try {
- driver.switchTo().alert();
- return true;
- } catch (NoAlertPresentException e) {
- return false;
- }
- }
- while (iterator.hasNext()){
- currentWindowId = iterator.next().toString();
- if (!currentWindowId.equals(parentHandle)){
- this.driver.switchTo().window(currentWindowId);
- WebElement frame = driver.findElement(By.id("STD_SEARCHER"));
- driver.switchTo().frame(frame);
- WebElement buttonOpt = this.driver.findElement(By.xpath("//*[@id='moreInfo1293951883']/button/span"));
- buttonOpt.click();
- }
- }
Add Comment
Please, Sign In to add comment