看起来我的代码是正确的,但并没有像预期的那样工作,Webdriver在我的代码中并没有真正工作。我希望在返回到前一页之前先加载该页。下面是我的代码。
Browser.clickElement(MenuButton, "XPath", _driver);
Browser.clickElement(Menus[i], "XPath", _driver);
for(int j=0; j<1; j++) //StrategySubLinks.length;
{
Browser.clickElement(StrategySubLinks[j], "XPath", _driver);
//wait for a certain element to be visible before going back to the previous page
//wait for the footer link
WebDriverWait wait = new WebDriverWait(_driver, 5);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"asdfdasf-asdfasdfcookie\"]/p/a[2]")));
//go back to previous page
//_driver.navigate().back();
_driver.navigate().refresh();
JavascriptExecutor js = (JavascriptExecutor) _driver;
js.executeScript("window.history.back();");https://stackoverflow.com/questions/41217494
复制相似问题