Do not dwell on HTTP 403 error

In one of my test cases of Selenium, I try to provide access to certain pages. Instead, an HTTP 403 return code should be specified.

However, here Selenium completes the test with the following exception:

com.thoughtworks.selenium.SeleniumException: XHR ERROR: URL = http://user:password@www.example.com/admin Response_Code = 403 Error_Message = Forbidden

How can I get around this?

+3
source share
3 answers

It seems that I myself must answer the question ...

Now I surround the "open" call with try ... catch block. There I parse the exception message if it contains the 403 code and the XHR ERROR. It seems to me not very clean, but it works.

+4
source

, , , , Selenium .

Ruby:

@browser.remote_control_command('open', [url, 'true'])

#:

((DefaultSelenium)selenium).Processor.DoCommand("open", new string[]{url, "true"}))

, Selenium trunk . , , .

+2

HTTP 403 PHPUnit. PHPUnit Selenium , , , , , .

try-catch Selenium:

try {
    $this->open('restricted_url');
    $this->assertTitle('The page cannot be displayed');
} catch (PHPUnit_Framework_Exception $e) {
    $this->start();
}

Selenium , , , , :

$this->loginAsGuest();

try {
    $this->open('admin_url');
    $this->assertTitle('The page cannot be displayed');
} catch (PHPUnit_Framework_Exception $e) {
    $this->start();
    $this->loginAsGuest();
}
+2

Source: https://habr.com/ru/post/1743194/


All Articles