开发者

Selenium: get Last-Modified HTTP header?

开发者 https://www.devze.com 2023-03-17 14:31 出处:网络
Is it possible to check whether a page is old (in that case this page will be skipped by the test) by evaluating the If-Modified-Since 开发者_Python百科HTTP header property of a page?

Is it possible to check whether a page is old (in that case this page will be skipped by the test) by evaluating the If-Modified-Since 开发者_Python百科HTTP header property of a page?

Is it possible to check this before the page is completely loaded, therefore saving some bandwith and time?

I am using RemoteWebDriver()


Your best bet might be to use BrowserMob Proxy, which is designed to work with Selenium and capture the HTTP traffic taking place during your test. I created BrowserMob Proxy based on the code we developed in Selenium RC (I'm the creator of that) and BrowserMob (a cloud performance testing service).


I'm not aware there's a built-in way to get the header specifically. You can instead use driver.getPageSource() and then parse the HTML with something like JSoup or Jericho.

Alternatively, cast your WebDriver object to a JavascriptExecutor and do this:

( (JavascriptExecutor) driver).executeScript("return document.lastModified;");
0

精彩评论

暂无评论...
验证码 换一张
取 消