How to identify an http (500) error via the Selenium web driver or javascript

Asked

Viewed 140 times

2

I need to build a script that scans certain pages and locate http errors, specific to 500. I thought about making a Selenium script, but I don’t know a command that I can "read" this kind of error. Can anyone tell me if Selenium has any commands for this, or javascript?

1 answer

1


Can anyone tell me if Selenium has any commands for this, or javascript?

Selenium itself, no. What you can do is fire a request using a shared session and collect the error status.

The package I know does that is the selenium-requests. An example:

from seleniumrequests import *

browser = Firefox();
# Faça algumas ações aqui, como autenticar login, se for o caso.
retorno_requisicao = browser.request('GET', "http://sitequalquer.com")
if retorno_requisicao.status_code >= 500:
    # Trate os erros aqui.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.