您可以在窗口之间切换,如下所示:// Store the current window handleString winHandleBefore = driver.getWindowHandle();// Perform the click operation that opens new window// Switch to new window openedfor(String winHandle : driver.getWindowHandles()){ driver.switchTo().window(winHandle);}// Perform the actions on new window// Close the new window, if that window no more requireddriver.close();// Switch back to original browser (first window)driver.switchTo().window(winHandleBefore);// Continue with original browser (first window)