1
- 轉到網頁元素上點擊:http://list.qoo10.sg/item/REAL-JAPAN-VERSION-WORTH-120-24K/412131433
- 向下滾動,直到你到達客戶審覈表
- 下表中有分頁標籤看起來像這樣
< 1 2 3 4 5 6 7 8 9 10 >無法使用HtmlUnitDriver
我需要點擊>
這意味着表格的下一頁
和代碼我用
WebDriver driver = new HtmlUnitDriver();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("http://list.qoo10.sg/item/REAL-JAPAN-VERSION-WORTH-120-24K/412131433");
WebElement findElement1 =
driver.findElement(By.cssSelector("td#opinion_point_1.rating"));
String htmlTableText = findElement1.getText();
System.out.println(htmlTableText);
TimeUnit.SECONDS.sleep(10);
//next click
WebElement click_button =
driver.findElement(By.cssSelector("div#paging.pagingInfo div.center a.next"));
boolean click2=click_button.getAttribute("href").contains("javascript:opinionList(2)");
click_button.click();
TimeUnit.SECONDS.sleep(10);
WebElement findElement2 =
driver.findElement(By.cssSelector("td#opinion_point_1.rating"));
String htmlTableText2 = findElement2.getText();
System.out.println(htmlTableText2);
driver.close();
driver.quit();
我打印元素後點擊&之前,但它不會改變。這意味着點擊不被執行。有什麼建議麼?
我嘗試了以下修復,但我得到了相同的結果
click_button.sendKeys(Keys.ENTER);
和
Actions action = new Actions(driver);
action.moveToElement(click_button).click().perform();
和
WebDriverWait wait = new WebDriverWait(driver, 10);
click_button = wait.until(ExpectedConditions.visibilityOfElementLocated(
By.cssSelector("div#paging.pagingInfo div.center a.next")));
click_button.click();
是否僅限htmlunit錯誤? – SkorpEN 2014-09-23 19:59:14
代碼運行沒有錯誤,但點擊沒有響應 – XXLend 2014-09-23 20:54:34
它只是htmlunit結果嗎?你是否和其他司機一起嘗試過? – SkorpEN 2014-09-23 21:05:16