In the below program we have created two browser instances i.e driver and driver1.
with one driver instance we are opening one URL and with second driver instance other URL.
Below code shows how we can switch the browser windows using different driver instances.
with one driver instance we are opening one URL and with second driver instance other URL.
Below code shows how we can switch the browser windows using different driver instances.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
public class FrameWorkBase {
// 'driver' and 'driver1' are two instances created.
public static WebDriver driver,driver1;
public static WebDriverWait wait;
public static String Parentwindow;
public static void main (String []args) throws Exception
{
driver= new FirefoxDriver();
driver.manage().window().maximize();
wait=new WebDriverWait(driver, 10);
driver.get("http://www.yahoo.com");
System.out.println(driver.getTitle());
Parentwindow = driver.getWindowHandle();
for ( String currentwindow : driver.getWindowHandles())
driver.switchTo( ).window(currentwindow);
{
driver1=new FirefoxDriver();
driver1.manage().window().maximize();
driver1.get("https://translate.google.co.in/");
System.out.println(driver1.getTitle());
driver.switchTo().window(Parentwindow);
}
System.out.println(driver.getTitle());
}
}
No comments:
Post a Comment