-1

I need to verify if opening the browser url is not landing to a particular page. Code snippet is a as below, where open is performed and the page displays 'couldn't open this url' but still exception is thrown from selenium

Error: "ERROR in invoking Selenium Commands:Timed out after 100000ms".

Selenium RC command

selenium.setTimeout("100000");
selenium.open(url);

How to verify negative url's via selenium

Giri
  • 411
  • 2
  • 18

2 Answers2

0

To open url in web browser

String browser = "firefox";
//String browser = "chrome";
//String browser = "ie";
@Test
public void googleSearch() {
    WebDriver driver = null;
    if (browser.equalsIgnoreCase("chrome")) {
        System.setProperty("webdriver.chrome.driver", "path-to-chromedriver\chromedriver.exe");
        driver = new ChromeDriver();
    }
    else if(browser.equalsIgnoreCase("ie")){
        System.setProperty("webdriver.ie.driver","path-to-IEdriver\IEdriver.exe");
        driver = new InternetExplorerDriver();
    }
    else {
        driver = new FirefoxDriver();
    }
    driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
    driver.manage().window().maximize();
    driver.get("http://www.google.com");
}
Sanjay Bhimani
  • 1,593
  • 1
  • 15
  • 29
  • i don't have issues in opening url. How to open url which doesn't exist and verify the landing page ??? – Giri Jan 21 '16 at 08:50
0

It could be achieve to get the HTTP status code of requested URL but selenium does not support to get HTTP status code (like 400, 500).

Other approach would be:-

--> Open URL

--> Put assertion for valid text on the page. (It will return fail if URL is invalid else URL is valid)

Ashish
  • 51
  • 3