1

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 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()

1
  • 1
    If-Modified-Since is an http request header. Do you mean Last-Modified? Commented Jul 4, 2011 at 12:26

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

1 Comment

1

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;");

4 Comments

The HTML source won't contain the HTTP headers
I assumed he meant lastModified
It won't contain any HTTP headers. +1 for workaround using js document object.
Will it work? ExecuteScript injects js into the document, so result will be current time. Isn't?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.