2017-08-13 63 views
-1

我正在使用页面对象模型,如测试,流程,pages.I想获取页面加载时间为控制台上的所有页面。一页到下一页。如何在selenium web驱动程序中获取所有页面的页面加载时间

您能否给我提供解决方案。 在此先感谢

+0

什么都尝试过从你的最后? – Alok

+1

欢迎来到Stack Overflow!请参阅:[我如何做X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-dox )对SO的期望是,用户提出的问题不仅仅是研究来回答他们自己的问题,而且还分享研究,代码尝试和结果。这表明你已经花时间去尝试帮助自己,它使我们避免重申明显的答案,最重要的是它可以帮助你得到更具体和相关的答案!另见:[问] – JeffC

回答

0

有没有直接的方法来计算硒在2页之间的时间。 您将不得不等待特定的webelement加载以获得页面加载时间。这不是最准确的方法,但它是唯一的方法。

有一个名为秒表的类可用于存储从一页移动到下一页所需的时间。

import org.apache.commons.lang3.time.StopWatch; /* import this class */ 

/* Initializing a StopWatch object */ 
public StopWatch stopWatch = new StopWatch(); 

stopWatch.start(); /* starting the clock */ 
driver.get(url);  /* start point of the page load */ 

wait.until(ExpectedConditions.visibilityOfElementLocated(by_id_locator)); 
stopWatch.stop();  /* stopping the clock */ 

/* Storing the page load time in a string variable */ 
String pageLoadTime = stopWatch.toString(); 

System.out.println(pageLoadTime); 
相关问题