psdbComponent.clickDocumentLink();
ArrayList<String> tabs2 = new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(tabs2.get(1));
driver.close();
driver.switchTo().window(tabs2.get(0));
This code perfectly worked for me. Try it out. You always need to switch your driver to new tab, before you want to do something on new tab.
More Related Contents:
- Exception in thread “main” org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[@id=’login-email’]
- Check if element is clickable in Selenium Java
- Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click
- How to avoid “StaleElementReferenceException” in Selenium?
- Is it possible to switch to an element in a frame without using driver.switchTo().frame(“frameName”) in Selenium Webdriver Java?
- Replace implicit wait with explicit wait (selenium webdriver & java)
- Page scroll up or down in Selenium WebDriver (Selenium 2) using java
- Selenium 2.53 not working on Firefox 47
- Selenium WebDriver How to Resolve Stale Element Reference Exception?
- Using Selenium WebDriver to retrieve the value of an HTML input
- How to gettext() of an element in Selenium Webdriver
- The type FluentWait is not generic; it cannot be parameterized with arguments error for FluentWait Class through Selenium and Java
- Equivalent of waitForVisible/waitForElementPresent in Selenium WebDriver tests using Java?
- Is there a way to use Selenium WebDriver without informing the document that it is controlled by WebDriver?
- org.openqa.selenium.WebDriverException: unknown error: call function result missing ‘value’
- Selenium Webdriver submit() vs click()
- java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;) with Selenium, gradle and ChromeDriver
- WebDriverException: unknown error: Runtime.executionContextCreated has invalid ‘context’: while initializing Chrome browser
- What is difference between Implicit wait and Explicit wait in Selenium WebDriver? [duplicate]
- java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V with IE and Selenium through Java
- getWindowHandles() not working in firefox 58.The focus remains on parent tab and does not transfer to next tab
- Test if an element is present using Selenium WebDriver
- Capturing browser logs with Selenium WebDriver using Java
- Getting StaleElementReferenceException while trying print the link names
- How to create a executable jar file for Testng and the runnnig point should be the Xml file
- How do I load a javascript file into the DOM using selenium?
- How to upload a file in Selenium with no text box
- How to scroll a specific DIV using Selenium WebDriver with Java?
- How to wait for an alert in Selenium webdriver ? [duplicate]
- UnreachableBrowserException Caused by: java.lang.NullPointerException when “webdriver.firefox.marionette” is used