What is the difference between getWindowHandle() and getWindowHandles() methods in Selenium WebDriver?

0 votes
What is the difference between getWindowHandle() and getWindowHandles() methods in Selenium WebDriver?
Jun 3, 2019 in Selenium by Jennifer
6,448 views

1 answer to this question.

0 votes

Hey Jennifer, difference between getWindowHandle() and getWindowHandles() methods is as follows:

driver.getWindowHandle() – It returns a handle of the current page (a unique identifier). It is used to get the address of the current browser where the control is and return type is String. Syntax is:

String handle = driver.getWindowHandle()

driver.getWindowHandles() – It returns a set of handles of the all the pages available. It is used to get the address of all the open browser and its return type is Iterator<String>. Syntax is:

<List> handles=driver.getWindowHandles();
answered Jun 3, 2019 by Anvi
• 14,110 points
The return type of the driver.getWindowHandles() is Set of String, not List of the String.
Thanks @Ankush for pointing out the error in this answer.

Related Questions In Selenium

0 votes
2 answers
0 votes
1 answer

What is the difference between WebDriver and RemoteWebdriver in Selenium?

Hey Ishan, the difference between Webdriver and ...READ MORE

answered May 10, 2019 in Selenium by Pratibha
• 3,690 points
7,138 views
0 votes
1 answer
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,520 points
10,524 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
3,804 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,786 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,758 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,120 views
+1 vote
2 answers
0 votes
1 answer

What are the differences between POM and PageFactory in Selenium Webdriver?

Hi Raveena, Page Object Model (POM) and ...READ MORE

answered Jul 17, 2019 in Selenium by Anvi
• 14,110 points
5,931 views