when I execute full script when child window opens its automatically execute next line of script i.e., "ac = web.find_element('xpath','//[id="ton"]')". How to wait for captcha input then after input when I chick on submit button it will execute next line of script.
from selenium import webdriver
from tkinter import *
from PIL import Image, ImageTk
root = Tk()
root.geometry("200x200")
def kcauto():
web = webdriver.Chrome()
global myimg
def capp():
ca = web.find_element('xpath', '/[id="captcha"]')
ca.send_keys(cvalue.get())
top = Toplevel()
top.title('second')
myimg = ImageTk.PhotoImage(Image.open('captcha.png'))
mylab = Label(top, image=myimg)
mylab.pack(pady=20)
myentry = Label(top)
myentry.pack()
cvalue = StringVar()
Centry = Entry(top, textvariable=cvalue)
Centry.pack(pady=20)
mybutton = Button(top, text='Submit', command=capp)
mybutton.pack()
ano = '031191'
ac = web.find_element('xpath','//[id="ton"]')
ac.send_keys(ano)
b2 = Button(root, fg="black", text="Single", padx=30, pady=20, command=kcauto)
b2.grid(row=2, column=2)
root.mainloop()
Getting Error:
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\ct\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "D:\ct\PycharmProjects\auto\ir.py", line 52, in kcauto
ac = web.find_element('xpath','//[id="ton"]')