On my web page are two different types of errors.
The first one is:
<div class="warning" data-text="text-field-error" dir="ltr">Diese ID ist nicht verfügbar.</div>
And the second one is:
<div class="separator-notice text-notice text-margin theme-noticeerror-font" dir="ltr">Bei der Verbindung zum Server ist eine Zeitüberschreitung aufgetreten.</div>
For example, if I try the wrong email, it doesn't have a specific value how often you can repeat. From time to time it's different. Now the first error means that this email (in my case ID) isn't valid.
The second error's meaning is that the Server connection has failed. Now with Selenium I want to handle these two different errors something like this:
for line in lines:
driver.find_element_by_id(input_id).send_keys(line)
driver.find_element_by_class_name(check_available).click()
count += 1
time.sleep(1)
try:
# Check if I get error one
except:
# I got an error two
else:
pass
I've already looked around at stack but couldn't find anything that matches my requirements. I also have tried it with xpath by text like this:
try:
driver.find_element_by_xpath("//div[contains(text(), ' Diese ID ist nicht verfügbar.')]")
except:
# It has to be error two
So my question is: How can I check which error I currently have and how can I work with that error. For example
if error1:
print("error_one")
if error2:
print("error_two")