I have created simple form to get user input but I am unable to retrieve those values when I need to be used, there are 3 inputs project id, layout id and format based on that need to make url and get load in browser, but this is not working.
Taking input from popup for SPID, Layout, choice variables but not able to retrieve and use enetered values. I have pasted my code what I exactly tried.
Can someone help me to resolve this.
from tkinter import simpledialog from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import time import tkinter as tk from tkinter import* def login_to_website(username1, password1): # Initialize the browser browser = webdriver.Chrome() # Use appropriate WebDriver for your browser base = Tk() base.geometry('500x500') base.title("Project Details") labl_0 = Label(base, text="Project details",width=20,font=("bold", 20)) labl_0.place(x=90,y=53) labl_1 = Label(base, text="Project SPID",width=20,font=("bold", 10)) labl_1.place(x=80,y=130) entry_1 = Entry(base) entry_1.place(x=240,y=130) labl_2 = Label(base, text="Layout ID",width=20,font=("bold", 10)) labl_2.place(x=68,y=180) entry_02 = Entry(base) entry_02.place(x=240,y=180) labl_3 = Label(base, text="Data Format",width=20,font=("bold", 10)) labl_3.place(x=70,y=230) varblbl = IntVar() Radiobutton(base, text="Excel",padx = 5, variable=varblbl, value=1).place(x=235,y=230) Radiobutton(base, text="Excel with Text",padx = 5, variable=varblbl, value=2).place(x=235,y=250) Radiobutton(base, text="OE Data",padx = 5, variable=varblbl, value=3).place(x=235,y=270) Button(base, text='Submit',width=20,bg='brown',fg='white',command=base.destroy).place(x=180,y=350) base.mainloop() SPID=entry_1.get() Layout=entry_02.get() format="" choice=varblbl.get() print(choice) if choice==1: format="format=xlsx" elif choice==2: format="format=xlsx&textual=1" elif choice==3: format="zip=1&fieldset=oe&format=xlsx" # Navigate to the website website = "https://singapore.decipherinc.com/rep/selfserve/596/"+str(SPID)+":excel?config=qualified&run=1&"+format+"&layout="+str(Layout)+"&language=english" # Replace with your website URL browser.get(website) # Find username and password fields and input credentials username_field = browser.find_element("name", "username") password_field = browser.find_element("name", "password") username_field.send_keys(username1) password_field.send_keys(password1) Trust = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, 'remember'))) browser.execute_script("document.getElementById('remember').click();") PolicyAccept = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Accept')]"))) PolicyAccept.click() # Find and click the "Sign In" button try: sign_in_button = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Sign In')]"))) sign_in_button.click() except: print("Sign In button not found or clickable.") # Close the browser time.sleep(120) browser.close() if __name__ == "__main__": # Replace with your actual username and password username1 = "XXXXXX" password1 = "XXXXXXX" login_to_website(username1, password1)