天天看點

Selenium關于滾動條的定位方法總結

說明:滾動條也分為很多種。需根據具體情況來決定使用哪種方法。

一、最普通滾動條,手動拖動可以到頁面任意位置 。 

滾動到指定元素的位置;

WebElement target = driver.findElement(By.xpath(xPathExpression));((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView();", target); 

本文轉自 honzhang 51CTO部落格,原文連結:http://blog.51cto.com/hongz/1764030

繼續閱讀