driver.findElement(By.xpath("")).click();
Thread.sleep(1000);
driver.findElement(By.xpath("")).click();
driver.navigate().back();
最佳答案
如果我理解正确,在代码片段中的 click()
之后,您将被重定向到另一个页面并且您想返回。您可以使用这个:
driver.findElement(By.xpath("")).click();
Thread.sleep(1000);
driver.findElement(By.xpath("")).click();
new WebDriverWait(driver, 10).until(ExpectedConditions.urlToBe("your_url"));
driver.navigate().back();
您必须等待,直到您被重定向到新页面,然后再返回。
注意:您必须添加一些导入:
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
关于java - 后台操作在 Selenium 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51683038/