0

I am trying to accessing the url using gebish.

Browser homePageBrowser = new Browser(driver: new HtmlUnitDriver())
HomePage.url = "http://edition.cnn.com/"
homePageBrowser.with {
    to HomePage
    pageTitle = title
}

Here is the code of HomePage.groovy

class HomePage extends Page {
    static url = "http://edition.cnn.com/"
    static content = {
    title {
        $("title").text()
    }
}

I am not getting response from cnn.com where as if i visit site manually in the browser i am able to get.This is only happening for "http://edition.cnn.com". I am able to get response for remaining urls. Please help me to fix this problem

tim_yates
  • 167,322
  • 27
  • 342
  • 338
Jagadeesh
  • 570
  • 3
  • 11
  • Does it work if you change: `Browser homePageBrowser = new Browser(driver: new HtmlUnitDriver())` to `Browser homePageBrowser = new Browser(driver: new HtmlUnitDriver(com.gargoylesoftware.htmlunit.BrowserVersion.CHROME))`? They might be sniffing the UserAgent and rejecting what they believe are scrapers – tim_yates Mar 11 '14 at 09:40
  • I will try and let you know. Interesting thing here if i insert print statement in the title closure of HomePage.groovy, it is working as expected. If i comment println statement it is not working. can you tell me why this is happening? – Jagadeesh Mar 11 '14 at 10:00
  • I tried with FireFox Version but still same issue – Jagadeesh Mar 11 '14 at 10:53
  • 2
    Finally found the problem. Problem with that site is having meta refresh in the header tags. including driver.webClient.refreshHandler = new ThreadedRefreshHandler() this code solved my problem – Jagadeesh Mar 11 '14 at 13:11
  • @Jagadeesh Since you solved the problem, add your answer below and accept it so others can see it is solved. :) – inanutshellus Mar 11 '14 at 19:37

1 Answers1

1

Problem with that site is having meta refresh in the header tags. including driver.webClient.refreshHandler = new ThreadedRefreshHandler() this code solved my problem

Jagadeesh
  • 570
  • 3
  • 11