You can try the following:
- Switch to the new opened tab.
- Close the current windows (in this case, the new tab).
-
Switch back to the first window.
browser.getAllWindowHandles().then(function (handles) { browser.driver.switchTo().window(handles[1]); browser.driver.close(); browser.driver.switchTo().window(handles[0]); });
More Related Contents:
- Locating an element by id
- What is the difference between WebDriver and WebElement in Selenium?
- StaleElementReference Exception in PageFactory
- How does chrome driver interact with Chrome browser?
- How can I take a screenshot with Selenium WebDriver?
- How to click on SVG elements using XPath and Selenium WebDriver through Java
- Using implicit wait in selenium
- Selenium Google Login Block
- Selenium: How selenium identifies elements visible or not? Is is possible that it is loaded in DOM but not rendered on UI?
- SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81
- Selenium WebDriver 3.4.0 + geckodriver 0.18.0 + Firefox ?? – which combination works?
- Error [SEVERE]: Timed out receiving message from renderer: 20.000 while executing the testsuite through Selenium on Jenkins
- Page load strategy for Chrome driver (Updated till Selenium v3.12.0)
- Unable to find a matching set of capabilities with selenium 3.4.3, firefox 54.0 and gecko driver 0.17
- release Selenium chromedriver.exe from memory
- What is benefit of using ChromeDriver over WebDriver if we are using only Chrome Browser in our Selenium Automation Script
- How to turn off w3c in chromedriver to address the error unknown command: Cannot call non W3C standard command while in W3C
- How to click on the reCAPTCHA using Selenium and Java
- What is the internal working difference between Implicit Wait and Explicit Wait
- ERROR:ssl_client_socket_openssl.cc(1158)] handshake failed with ChromeDriver Chrome browser and Selenium
- Custom browser actions in Protractor
- Creating XPATH for svg tag
- Selenium Webdriver wait Expected condition failed: waiting for visibility of element located by By.id
- Get PID of Browser launched by selenium
- Using an OR condition in Xpath to identify the same element
- Is there a Selenium WebDriver available for the Microsoft Edge browser?
- selenium implicitly wait doesn’t work
- Browser performance tests through selenium
- How to switch control from child window to parent window in selenium webdriver?
- Only local connections are allowed Chrome and Selenium webdriver