What I want is to continue with the next iteration if there is a pop up message in the webpage being scrapped. That is if there is any pop up message, I want to accept that message and go to the next item i.e go to the beginning of the loop.
For this I use the following snippet of code:
from tkinter import *
from tkinter import messagebox as msg
from tkinter import filedialog as fd
from tkinter import ttk
from tkinter import StringVar as sv
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
for(i in range(0,5)):
try:
click_alert=driver.switch_to_alert()
click_alert.accept()
continue
except TimeoutException:
print('wrong value in'+i+'th row . Please check the value ')
The following error shows up:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "C:/Users/chowdhuryr/Desktop/ATT RESEARCH BOT/GUI.py", line 64, in printMessage
self.Scrapper(str1,str2)
File "C:/Users/chowdhuryr/Desktop/ATT RESEARCH BOT/GUI.py", line 163, in Scrapper
click_alert=driver.switchTo().alert()
Now I am pretty certain that the error lies in click_alert=driver.switch_to_alert() because I have checked it using some sanity checks.