I have a Selenium 3 Python script that is used to file FTC complaints for nuisance calls. Today a miscreant got through using the number "0" (literal 0). The FTC website rejected the number but my script failed to detect the failure.
Here is the relevant portion of my Python script that drives the complaint process. Here is a pastebin of the FTC page that is rejecting the number. According to the Selenium docs there is no return value from button_continue.click()
(if I am parsing the docs correctly; see around the heading User Input - Filling In Forms).
# print("Clicking Continue")
button_continue = driver.find_element_by_id("StepTwoSubmitButton")
button_continue.click()
I also purchased the book Test-Driven Development with Python, but the Selenium hits I found when searching online turned out to be two pages in the book. (It was very disappointing; not recommended for this type of task, despite the title of the book).
My question is, how do I detect the failures using Selenium 3?
Here is the specific Javascript for the FTC page causing the trouble. It is from the pastebin:
<div class="s_form_verif_bttn_sl">
<label for="StepTwoSubmitButton">
<input type="submit" name="StepTwoSubmitButton" value="Submit" onclick="validateform();WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("StepTwoSubmitButton", "", true, "StepTwoEntry", "", false, false))" id="StepTwoSubmitButton" accesskey="s" tabindex="17" class="th_s" />
</label>
<label for="StepTwoCancelButton">
<input type="submit" name="StepTwoCancelButton" value="Cancel" id="StepTwoCancelButton" accesskey="s" tabindex="18" class="th_s" />
</label>
</div>
I was able to reproduce the submit failure manually. Below is a screen capture of the result of submitting the form. When I watched the process in Developer Console I did not see anything out of the ordinary, like an uncaught exception.
Here are package versions.
$ apt-cache policy chromium-browser
chromium-browser:
Installed: 73.0.3683.86-0ubuntu0.18.04.1
Candidate: 73.0.3683.86-0ubuntu0.18.04.1
$ apt-cache policy python3-selenium
python3-selenium:
Installed: 3.8.0+dfsg1-3
Candidate: 3.8.0+dfsg1-3
$ apt-cache policy chromium-chromedriver
chromium-chromedriver:
Installed: 73.0.3683.86-0ubuntu0.18.04.1
Candidate: 73.0.3683.86-0ubuntu0.18.04.1
$ apt-cache policy python3
python3:
Installed: 3.6.7-1~18.04
Candidate: 3.6.7-1~18.04