Thank you Subhasish for this very useful video ,but the piece of code for handling multiple windows in selenium(Qs. 11) is not very clear. Can you please paste the code in comment section .It will really be helpful for me.
Please find below piece of code. public class MultipleWindowsClass { @Test public void testMultipleWindows() throws InterruptedException{ System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"\\src\\test\\java\\drivers\\geckodriver.exe"); // To open browser WebDriver driver=new FirefoxDriver(); // To maximize browser driver.manage().window().maximize(); // To open Naukri website with multiple windows driver.get("www.naukri.com/"); // It will return the parent window name as a String String mainWindow=driver.getWindowHandle(); // It returns no. of windows opened by WebDriver and will return Set of Strings Set set =driver.getWindowHandles(); // Using Iterator to iterate with in windows Iterator itr= set.iterator(); while(itr.hasNext()){ String childWindow=itr.next(); // Compare whether the main windows is not equal to child window. If not equal, we will close. if(!mainWindow.equals(childWindow)){ driver.switchTo().window(childWindow); System.out.println(driver.switchTo().window(childWindow).getTitle()); driver.close(); } } // This is to switch to the main window driver.switchTo().window(mainWindow); } }
Thanks for the most Informational video. You have covered each area and we can explore more knowledge on them.
GREAT JOB💯💯👍👍👏👏
Glad it was helpful!!! Keep learning and sharing with your friends 😊
Thanks for sharing this video , very helpful for the interview keep doing the good work and add more important interview questions as per the market.
Thank you for your nice words :-) I will keep on adding more contents.
Very helpful Subhasish... Thanks
Always welcome
Thanks sir for sharing this video.... it's really helpful
Glad to hear that!! Keep learning and sharing with your friends 😊
Very useful thankew
Welcome 😊 Share it with your friends.
Thank you
You're welcome
Thank you Subhasish for this very useful video ,but the piece of code for handling multiple windows in selenium(Qs. 11) is not very clear. Can you please paste the code in comment section .It will really be helpful for me.
Please find below piece of code.
public class MultipleWindowsClass {
@Test
public void testMultipleWindows() throws InterruptedException{
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"\\src\\test\\java\\drivers\\geckodriver.exe");
// To open browser
WebDriver driver=new FirefoxDriver();
// To maximize browser
driver.manage().window().maximize();
// To open Naukri website with multiple windows
driver.get("www.naukri.com/");
// It will return the parent window name as a String
String mainWindow=driver.getWindowHandle();
// It returns no. of windows opened by WebDriver and will return Set of Strings
Set set =driver.getWindowHandles();
// Using Iterator to iterate with in windows
Iterator itr= set.iterator();
while(itr.hasNext()){
String childWindow=itr.next();
// Compare whether the main windows is not equal to child window. If not equal, we will close.
if(!mainWindow.equals(childWindow)){
driver.switchTo().window(childWindow);
System.out.println(driver.switchTo().window(childWindow).getTitle());
driver.close();
}
}
// This is to switch to the main window
driver.switchTo().window(mainWindow);
}
}
@@SoftwareTestingAndAutomation Thank you so much
Everything is good but the colour you used that is painful for eyes. So need to use white background that will better for everyone.
Thank you for the feedback. I have already taken care it in my new videos.
In every video us screen colour in changing . that's getting problem.
Please change the background color and text color not at visible
Thanks much
You're welcome!