У нас вы можете посмотреть бесплатно ✔ Selenium 4 New Window - Tab Concept: How To Open & Switch With 1 Code Line | (Video 154) или скачать в максимальном доступном качестве, которое было загружено на ютуб. Для скачивания выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса savevideohd.ru
Selenium 4 New Window - Tab Concept: How To Open & Switch ► Watch Complete Selenium 4 Playlist/Series • Selenium 4 New Features ► Download Presentation & Transcript https://github.com/RexJonesII/Free-Vi... ► Free Selenium PDF Book: https://www.rexjones2.com/book-seleni... ► Free Java PDF Book: https://www.rexjones2.com/book-part-1... ► All Paperback & eBooks: http://tinyurl.com/Rex-Allen-Jones-Books Social Media Contact ✔ YouTube / rexjonesii ✔ Twitter / rexjonesii ✔ LinkedIn / rexjones34 ✔ GitHub https://github.com/RexJonesII/Free-Vi... ✔ Facebook / jonesrexii ► Transcript Selenium 4 allows us to open a new window and open a new tab in the same session at the same time. After opening the window or tab, we have the ability to work in it without creating a new driver. Concept of Opening A New Window/Tab In this video, we are going to look at the concept of opening a new window and a new tab. With previous versions of Selenium, we could use the Robot Class to simulate the keyboard and open a new tab by pressing CTRL + T then switching focus to the tab after getting the window handle. Now, we can perform those same steps with Selenium 4 using 1 line of code: We can use it for a window or tab. driver.switchTo().newWindow(WindowType.WINDOW or TAB).get(url); Notice, WINDOW and TAB are written in green. • driver is used to control the browser • switchTo() is a method that sends commands to a window. It switches focus between the windows • newWindow() is a method that creates a new window or tab then automatically switches focus to that new window or tab • WindowType is an enum. Enum is short for enumeration which is a list of constants that define a new data type. In this case, the constants are WINDOW and TAB that instructs our program to open a new window or new tab. • WINDOW is the parameter for creating a new window • TAB is also a parameter but it’s used for creating a new tab • Last is the get(url) method which loads a new page in our browser Demo For our Test Script, we have a set up method to load an Automation Practice website then get the title. I commented out the tear down method because I want the page to stay open after executing our Test Script. Let’s start the test by writing @Test / public void testNewWindowConcept () { } driver.switchTo().newWindow(WindowType.TAB); If I hover the newWindow() method, and the description states “Creates a new browser window and switches the focus for future commands of this driver to the new window”. In shorter words, it will open a new window then switch focus to that window. We also see the parameters are type hint which is a type of new browser window to be created. The type hint will be WINDOW or TAB. Returns this driver focused on the given window. When it says window, it’s referring to a window or a tab. That’s why I was able to write WindowType.TAB. One more point, do you see how the Return Type is WebDriver? If we choose to, we can assign this statement to WebDriver with any name like newPage =. Let’s Run. We have 2 tabs and a blank page is opened with automatic focus in the new tab. The same outcome happens with a new window. Change TAB to WINDOW then run. A blank page is opened in a new window. For our Test Script, after the blank page, we are going to open the Contact Us page. Let me grab this URL and load a new page by writing newPage.get(“Paste the URL”) and print the page title sysout (“Title: ” + driver.getTitle()). Let’s Run. Both titles are displayed in the Console: My Store and Contact Us – My Store. Next, I will show you how to open, switch, work in the new tab then switch back to the parent tab. #Selenium4 #HowToOpenNewWindowTab