这是html代码
<div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 350px;"><div class="scroller" style="height: 350px; overflow: hidden; width: auto;" data-always-visible="1" data-rail-visible1="0" data-handle-color="#D7DCE2">
<div class="tsk-row clearfix">
<div class="tsk-left">
<a href="/WorkTask/Update/776eab95-d7ea-4b5d-9c58-1c736e071895">New task to check new build of 2016.4.18.1 </a>
</div>
<a href="/WorkTask/Index/45d76b1d-f665-4e29-b22f-5c9cd335a957">test</a>
<div class="tsk-right">
<span class="label label-warning">Assigned</span>
</div>
</div>
<div class="tsk-row clearfix">
<div class="tsk-left">
<a href="/WorkTask/Update/e78ed656-c8d1-4623-b2f7-a70876d80a9d"> test 2</a>
</div>
<a href="/WorkTask/Index/01ebc490-08d3-46f5-b9f7-139f3837e289"> test</a>
<div class="tsk-right">
<span class="label label-warning">Assigned</span>
</div>
</div>
<div class="tsk-row clearfix">
<div class="tsk-left">
<a href="/WorkTask/Update/9a992f63-f331-4e5b-a04b-b2e2bdbaa6c1"> test</a>
</div>
<a href="/WorkTask/Index/01ebc490-08d3-46f5-b9f7-139f3837e289"> test</a>
<div class="tsk-right">
<span class="label label-warning">Assigned</span>
</div>
</div>
<div class="tsk-row clearfix">
<div class="tsk-left">
<a href="/WorkTask/Update/36fe32fd-f06b-47da-99d6-b3fdc060528d"> New login page</a>
</div>
<a href="/WorkTask/Index/01ebc490-08d3-46f5-b9f7-139f3837e289"> test</a>
<div class="tsk-right">
<span class="label label-warning">Assigned</span>
</div>
</div>
<div class="tsk-row clearfix">
<div class="tsk-left">
<a href="/WorkTask/Update/0af36bce-755e-4744-b17b-85be5f263bf8"> new task </a>
</div>
<a href="/WorkTask/Index/a7a8967d-0945-4b69-95d9-59026a1181ef">Ongoing</a>
<div class="tsk-right">
<span class="label label-warning">Assigned</span>
</div>
</div>
<div class="tsk-row clearfix">
<div class="tsk-left">
<a href="/WorkTask/Update/8438470a-e19d-433b-8fa6-d6ff051db570">This is testing </a>
</div>
<a href="/WorkTask/Index/01ebc490-08d3-46f5-b9f7-139f3837e289"> test</a>
<div class="tsk-right">
<span class="label label-warning">Assigned</span>
</div>
</div>
</div>
</div><div class="slimScrollBar" style="width: 7px; position: absolute; top: 0px; opacity: 0.4; display: none; border-radius: 7px; z-index: 99; right: 0px; height: 300.245px; background: rgb(0, 0, 0);"></div><div class="slimScrollRail" style="width: 7px; height: 100%; position: absolute; top: 0px; display: none; border-radius: 7px; opacity: 0.2; z-index: 90; right: 0px; background: rgb(51, 51, 51);"></div></div>
这是我的自动化测试用例
公共 void openAllTask() 抛出 InterruptedException{
List<WebElement> task=driver.findElements(By.cssSelector(".tsk-row.clearfix")); // get the list of total no of elements present in the task window
System.out.println("size of i loop "+task.size());
for(int i=1; i<=task.size(); i++){
//find the element one by one using xpath
System.out.println(driver.findElement(By.xpath("html/body/div[2]/div[3]/div/div/div/div[3]/div/div[1]/div["+i+"]/div[1]/a")).getText());
driver.findElement(By.xpath("html/body/div[2]/div[3]/div/div/div/div[3]/div/div[1]/div["+i+"]/div[1]/a")).click();
Thread.sleep(3000);
driver.navigate().back();
Thread.sleep(3000);
// find the scroll bar and move the scroll bar by cirten pixles
WebElement element=driver.findElement(By.xpath("html/body/div[2]/div[3]/div/div/div/div[3]/div/div[2]"));
Actions act=new Actions(driver);
act.dragAndDropBy(element, 0, (i*10)).build().perform();
Thread.sleep(3000);
}
我想从突出显示的窗口中选择每个元素,然后向下滚动窗口,以便在添加动态元素时,我可以向下滚动并读取所有元素。