Unable to Switch in between the windows in IE11 in java selenium webdriver

231 views
Skip to first unread message

Sabita Padhi

unread,
Jan 17, 2017, 9:47:30 PM1/17/17
to Selenium Users
Hello,
In my project, requirement is to implement it in IE browser, I have IE 11 and selenium 2.53 version. I have parent window and after clicking a link my child window is opened I have to perform some task in child window and have to close it and again back to parent window.bur i am unable to transfer the control from parent to child.please help me.


Regards,
Kunmun

Sekhar Jasty

unread,
Jan 17, 2017, 10:28:03 PM1/17/17
to seleniu...@googlegroups.com
Hi, 
    Below piece of code should do the Job.

public static void main(String[] args) {

String drPath = "C:\\Desktop\\IEDriverServer.exe";
System.setProperty("webdriver.ie.driver", drPath);
WebDriver driver = new InternetExplorerDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://website.com");
String handle = driver.getWindowHandle();
System.out.println(handle);
driver.findElement(By.xpath("xpath of child window link")).click();
Set<String> handles = driver.getWindowHandles();
System.out.println(handles);

for (String handle1 : driver.getWindowHandles()) {
System.out.println(handle1);

driver.switchTo().window(handle1);

}

driver.close();
driver.quit();
}



Thanks,
Bala


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/3c62280c-0905-47b6-9711-6c229031d2b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sabita Padhi

unread,
Jan 18, 2017, 12:40:18 PM1/18/17
to Selenium Users
Hi Bala,
Already tried with this but still unable to switch.Please suggest me something new, its urgent.
Reply all
Reply to author
Forward
0 new messages