package script;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;
public class HandlingWindows {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
WebDriverBackedSelenium selenium = new WebDriverBackedSelenium(driver, "http://www.way2sms.com/");
driver.get("http://www.way2sms.com/");
selenium.windowFocus();
selenium.windowMaximize();
driver.findElement(By.xpath(".//*[@id='header']/div/div/div[2]/a")).click();
selenium.waitForPageToLoad("30000");
System.out.println("Page title is: " + driver.getTitle());
driver.findElement(By.id("username")).click();
Set allWindowHandles = driver.getWindowHandles();
String window0 = (String) allWindowHandles.toArray()[0];
System.out.println("Window0 String: "+ window0);
driver.switchTo().window(window0);
String win0Title = selenium.getTitle();
System.out.println("Window0 Title: "+ win0Title);
String window1 = (String) allWindowHandles.toArray()[1];
System.out.println("Window1 String: "+ window1);
driver.switchTo().window(window1);
String win1Title = selenium.getTitle();
System.out.println("Window1 Title: "+ win1Title);
}
}
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;
public class HandlingWindows {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
WebDriverBackedSelenium selenium = new WebDriverBackedSelenium(driver, "http://www.way2sms.com/");
driver.get("http://www.way2sms.com/");
selenium.windowFocus();
selenium.windowMaximize();
driver.findElement(By.xpath(".//*[@id='header']/div/div/div[2]/a")).click();
selenium.waitForPageToLoad("30000");
System.out.println("Page title is: " + driver.getTitle());
driver.findElement(By.id("username")).click();
Set
String window0 = (String) allWindowHandles.toArray()[0];
System.out.println("Window0 String: "+ window0);
driver.switchTo().window(window0);
String win0Title = selenium.getTitle();
System.out.println("Window0 Title: "+ win0Title);
String window1 = (String) allWindowHandles.toArray()[1];
System.out.println("Window1 String: "+ window1);
driver.switchTo().window(window1);
String win1Title = selenium.getTitle();
System.out.println("Window1 Title: "+ win1Title);
}
}
public static void main(String args[])throws Exception{
ReplyDeleteWebDriver driver = new FirefoxDriver();
driver.get("http://site21.way2sms.com/content/index.html");
driver.findElement(By.id("username")).sendKeys("9491885788");
driver.findElement(By.id("password")).sendKeys("3399");
System.out.println(driver.getTitle());
driver.findElement(By.id("loginBTN")).click();
driver.findElement(By.xpath(".//*[@id='ebFrm']/div[2]/div[1]/input")).click();
driver.findElement(By.xpath(".//*[@id='sendSMS']/a")).click();
//driver.findElement(By.id("textArea")).sendKeys("9491885788");
WebElement paragraph=driver.findElement(By.cssSelector("#mobile"));
List inputs=paragraph.findElements(By.tagName("input"));
for(WebElement input:inputs){
if ("Mobile Number".equals(input.getAttribute("placeholder")))
{ input.sendKeys("9818048682"); } }
}
}