У нас вы можете посмотреть бесплатно How to handle New Window or multiple windows on a webpage II WebDriver II Selenium Automation или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
In this session you will learn how to handle new window or tab and also how to switch to multiple windows and read elements If you want to practice programs/examples, please import the project from below GitHub Repo https://github.com/knowledgeshare-tec... Selenium Basic Sessions Playlist ======================== • Handling Alerts - Different Types of Alert... Notes on New Window ------------------------------------------- What is New Window An another window that is opened when you perform some action on a webpage Example : Clicking a link to navigate to different webpage Different Methods available to handle Windows getWindowHandle( ): To get the Current/Parent Window ID ( Return type is String ) getWindowHandles( ): To get all the Child windows opened by WebDriver ( Return type is Set,String ) switchto(): To Switch to Child Windows action: To Perform some actions on a Window Syntax to Switch to child window driver.switchTo.window(ChildWindowName); Program : ================== package com.seleniumbasics; import java.util.Iterator; import java.util.Set; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class NewWindow_Handling_Example { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", ".\\drivers\\chromedriver.exe"); WebDriver driver=new ChromeDriver(); driver.navigate().to("http://the-internet.herokuapp.com/win..."); driver.manage().window().maximize(); driver.findElement(By.xpath("//a[text()='Click Here']")).click(); //Get handle of a parent window String mainWindowHandle=driver.getWindowHandle(); System.out.println("Parent Window ID is : " + mainWindowHandle); //Get handles of child Windows SetLTStringGT allWindowHandles =driver.getWindowHandles(); IteratorLTStringGT iterator=allWindowHandles.iterator(); while(iterator.hasNext()) { String child_window=iterator.next(); System.out.println("Window ID : " + child_window ); if(!mainWindowHandle.equalsIgnoreCase(child_window)) { driver.switchTo().window(child_window); String text_on_new_window = driver.findElement(By.xpath("//*[text()='New Window']")).getAttribute("innerHTML"); System.out.println("Text on new window is : " + text_on_new_window); } } } }