不要停止HTTP错误403 [英] Don't stop on HTTP error 403

查看:145
本文介绍了不要停止HTTP错误403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个Selenium测试用例中,我尝试确保某些页面无法访问。应该给出HTTP返回代码403。

In one of my Selenium test cases, I try to ensure that certain pages can't be accessed. Instead, HTTP return code 403 should be given.

但是,这里Selenium会终止测试执行,但有以下异常:

However, here Selenium terminates test execution with the following exception:

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

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

任何工作方式那么?

推荐答案

似乎我必须自己回答这个问题...

Seems like I have to answer the question myself...

我现在用一个try ... catch块包围打开的电话。在那里,我解析异常消息,如果它包含403代码和XHR错误。似乎对我来说不是很干净,但它的作品。

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

这篇关于不要停止HTTP错误403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆