单击一行后,它将打开一个新选项卡,并将您重定向到该选项卡,重定向后,我想要的是跳回到原始选项卡 原始标签页链接为= http://localhost:82/receivechecklist.php,在单击该行后将其重定向到= http://localhost:82/collection.php?wid=100000000000001
private static By clickFirstInvoice=By.xpath("//span[contains(text(),'Customer 1')]");
driver.findElement(clickFirstInvoice).click();
Thread.sleep(500);
new WebDriverWait(driver,10).until(ExpectedConditions.numberOfWindowsToBe(2));
driver.switchTo().window(driver.getWindowHandles().stream().reduce((f, s) -> s).orElse(null));
System.out.println("Successful in switching to collection tab");
我要在点击发票后返回到原始标签
答案 0 :(得分:0)
在切换选项卡之前,您需要保存当前的窗口句柄。
String originalTab = driver.getWindowHandle();
//perform your switch here
driver.switchTo().window(originalTab);