Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98814

python tkinter not setting option menu to a variable? trying to work with selenium

$
0
0

I am trying to make a GUI that if I set the options menu to option a, for example, it will open the website and search whatever I write on the website for some reason, my code just does nothing after the GUI part

from tkinter import *
from selenium import webdriver

website = ""

root = Tk()

#configs
root.config(bg='grey')
root.title('easy chrome')
root.geometry('300x600')
root.resizable(width=False, height=False)

#quit button
quit_button = Button(root, text='quit', command=root.quit)

#drop down platform
clicked = StringVar()
platform = OptionMenu(root, clicked, 'kissanime', 'youtube', 'egybest')
clicked.set('pick the platform')
platform["menu"].config(bg="#A3CB37")  #drop down menu color
platform.config(bg='#2ecc72') # set menu color

#search box
search_box = Entry(text='Enter a search term.', borderwidth=5, bg='#487EB0')
search_text = search_box.get()
#if statements
if clicked == 'kissanime':
    website = 'https://kissanime.ru'

elif clicked == 'youtube':
    website = 'https://www.youtube.com'

elif clicked == 'egybest':
    website = 'https://lion.egybest.pw'


#def
def auto():
    global website
    browser = webdriver.Chrome()
    if clicked == 'youtube':
        browser.get('https://www.youtube.com/')
        youtube_search = browser.find_element_by_xpath('/html/body/ytd-app/div/div/ytd-masthead/div[3]''/ytd-searchbox/form/div/div[1]/input')
        youtube_search.send_keys(search_text)
    elif clicked == 'kissanime':
        browser.get('https://kissanime.ru/')
        kissanime_search = browser.find_element_by_xpath('/html/body/div[1]/div[1]/h3/div[2]/form/p/input[1]')
        kissanime_search.send_keys(search_text)
    elif clicked == 'egybest':
        browser.get('https://lion.egybest.pw/')
        egy_search = browser.find_element_by_xpath('/html/body/div[3]/div/div[2]/form/input[2]')
        egy_search.send_keys(search_text)

#submit button
submit_button = Button(bg='#FF3E4D', fg='#DAE0E2', text='submit', command=auto)

#griding
platform.grid(row=0, column=0, columnspan=2)
search_box.grid(row=1, column=0)
submit_button.grid(row=1, column=1)
quit_button.grid(row=2, column=1, columnspan=1)

root.mainloop()

this is the full code just cannot understand why does the browser.get command not working


Viewing all articles
Browse latest Browse all 98814

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>