Professional Documents
Culture Documents
-> We need to create an instance of the Actions class by passing the instance of
driver class
to the constructor in the following way:
Actions builder = new Actions(driver);
-> Syntax :
Set<String> windowIds = driver.getWindowHandles(); //to get the ids all windows
opened by selenium at the moment.
Iterator<String> it = windowIds.iterator(); //creating an iterator instance to
iterate through the set above.
String parentId = it.next(); //gives the first element in the set i.e. the parent
window id
String childId = it.next(); //gives the second element in the set i.e. the second
window opened by selenium and so on
driver.switchTo().windows(childId); //to switch selenium driver control over the
desired window.
->to identify if a weblement is in a frame, check it's parent tags in html, one of
them will be "iframes".
or in firefox, top right corner, something in css with the word iframe will will be
displayed on inspecting element
-> After the tasks in the frame are complete, selenium doesn't switch out of the
frame automatically.
the following statement needs to be executed in order to move the webdriver out of
the frame and into the default webpage :
driver.switchTo().defaultContent();
//switch to frame2
driver.switchTo().frame("frame2");
driver.findElement(By.xpath("//input[@value='Boat']")).click();