0

我定义了一个 WebDriver,进入一个示例页面:http : //webscraper.io/test-sites/e-commerce/more/computers/tablets,然后多次单击“LoadMore”按钮。它们都不起作用。

这就是我使用它的方式(在 scala 中,如果你愿意,我可以用 Java 翻译和测试):

  val baseCaps = new DesiredCapabilities
  baseCaps.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true)
  baseCaps.setCapability("takesScreenshot", true)
  baseCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, <my binary path>)

val driver = new PhantomJSDriver(baseCaps)

driver.get("http://webscraper.io/test-sites/e-commerce/more/computers/tablets")
    val wait = new WebDriverWait(driver, 10)
    val element = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(selector)))
    element.click()
<wait for a few seconds>
val page = driver.getPageSource.getBytes("UTF8")

PageSource 显示还是点击之前的页面

4

0 回答 0