I define a WebDriver, get to an example page: http://webscraper.io/test-sites/e-commerce/more/computers/tablets, and click "LoadMore" button for several times. None of them works.
This is how I use it (in scala, I can translate and test in Java if you want):
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 shows that it is still the page before clicking
来源:https://stackoverflow.com/questions/27466662/selenium-phantomjs-doesnt-work-on-http-webscraper-io-test-sites-e-commerce-mo