Error:
unindent does not match any outer indentation level
Code:
def confirmation(self):
if WebDriverWait(self.driver, 1000).until(
EC.visibility_of_element_located((By.CLASS_NAME, 'failed'))):
print("Checkout Failed!")
if WebDriverWait(self.driver, 1000).until(
EC.visibility_of_element_located((By.CLASS_NAME, 'succesful'))):
print("Checkout Succesful!")
How can I address the error?
This error message...
unindent does not match any outer indentation level
...implies that there is a problem with the indentation in your code block.
This error is mostly observed when there is a mixup of Tab and Space characters while indenting Python code.
When I copied you code block and executed:
I got the same error:
C:\Users\username\Desktop\directory\PyPrograms>class_in_python.py
File "C:\Users\Soma Bhattacharjee\Desktop\Debanjan\PyPrograms\class_in_python.py", line 26
def confirmation(self):
^
IndentationError: unindent does not match any outer indentation level
Once, I removed all the white paces and the new line character and break up the line again for the following line of code, the default indentation seems to be different:
if WebDriverWait(self.driver, 1000).until(
EC.visibility_of_element_located((By.CLASS_NAME, 'succesful'))):
print("Checkout Succesful!")
You need to fix up the indentation of the following lines:
EC.visibility_of_element_located((By.CLASS_NAME, 'failed'))):
EC.visibility_of_element_located((By.CLASS_NAME, 'succesful'))):
You can find a relevant detailed discussion in Is there something issue in indentation, while using Anaconda's Spyder