Tag: paging

加载页面后,selenium获取当前URL

我在Java中使用Selenium Webdriver。 我想在点击“下一步”按钮后从第1页到第2页获取当前url。这是我的代码: WebDriver driver = new FirefoxDriver(); String startURL = //a starting url; String currentURL = null; WebDriverWait wait = new WebDriverWait(driver, 10); foo(driver,startURL); /* go to next page */ if(driver.findElement(By.xpath(“//*[@id=’someID’]”)).isDisplayed()){ driver.findElement(By.xpath(“//*[@id=’someID’]”)).click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(“//*[@id=’someID’]”))); currentURL = driver.getCurrentUrl(); System.out.println(currentURL); } 在获取当前url之前,我有隐式和显式等待调用等待页面完全加载。 但是,它仍然打印出第1页的url(预计它将成为第2页的url)。