package Assignments;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class IrctcMultiWin {
public static void main(String[] args) {
//Step1
WebDriver driver = new FirefoxDriver();
driver.get("https://irctc.co.in");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//step2
Actions act = new Actions(driver);
WebElement tele = driver.findElement(By.xpath("//span[contains(text(),'Tourism')]"));
act.moveToElement(tele).perform();
//step3
driver.findElement(By.xpath("//a[text()='Tourist Train']")).click();
Set<String> set1 = driver.getWindowHandles();
//step4
Iterator<String> it = set1.iterator();
String parentId = it.next();
String childId = it.next();
//step5
driver.switchTo().window(childId);
//step6
driver.findElement(By.xpath("//h1[contains(text(),'Bharat Darshan')]/following-sibling::a[text()='Know More']")).click();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Set<String> set2 = driver.getWindowHandles();
//step7
Iterator<String> it1 = set2.iterator();
parentId = it1.next();
childId = it1.next();
String subChildId = it1.next();
//step8
driver.switchTo().window(subChildId);
//step9
String webTxt = driver.findElement(By.xpath("//p[contains(text(),'Hall')]")).getText();
System.out.println(webTxt);
driver.close();
//step10
driver.switchTo().window(childId);
driver.close();
//step11
driver.switchTo().window(parentId);
driver.findElement(By.id("usernameId")).sendKeys("sample@irctc.co.in");
driver.findElement(By.className("loginPassword")).sendKeys("hdhdyhd");
}
}
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class IrctcMultiWin {
public static void main(String[] args) {
//Step1
WebDriver driver = new FirefoxDriver();
driver.get("https://irctc.co.in");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//step2
Actions act = new Actions(driver);
WebElement tele = driver.findElement(By.xpath("//span[contains(text(),'Tourism')]"));
act.moveToElement(tele).perform();
//step3
driver.findElement(By.xpath("//a[text()='Tourist Train']")).click();
Set<String> set1 = driver.getWindowHandles();
//step4
Iterator<String> it = set1.iterator();
String parentId = it.next();
String childId = it.next();
//step5
driver.switchTo().window(childId);
//step6
driver.findElement(By.xpath("//h1[contains(text(),'Bharat Darshan')]/following-sibling::a[text()='Know More']")).click();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Set<String> set2 = driver.getWindowHandles();
//step7
Iterator<String> it1 = set2.iterator();
parentId = it1.next();
childId = it1.next();
String subChildId = it1.next();
//step8
driver.switchTo().window(subChildId);
//step9
String webTxt = driver.findElement(By.xpath("//p[contains(text(),'Hall')]")).getText();
System.out.println(webTxt);
driver.close();
//step10
driver.switchTo().window(childId);
driver.close();
//step11
driver.switchTo().window(parentId);
driver.findElement(By.id("usernameId")).sendKeys("sample@irctc.co.in");
driver.findElement(By.className("loginPassword")).sendKeys("hdhdyhd");
}
}
No comments:
Post a Comment