selenium python tkinter

Solutions on MaxInterview for selenium python tkinter by the best coders in the world

showing results for - "selenium python tkinter"
Mia
17 Aug 2016
1import tkinter as tk
2import selenium.webdriver
3
4# --- functions ---
5
6def on_open():
7    global driver
8
9    if not driver:
10        driver = selenium.webdriver.Firefox()
11        url = e.get()
12        driver.get(url)
13
14def on_close():
15    global driver
16
17    if driver:
18        driver.close()
19        driver = None
20
21# --- main ---
22
23driver = None
24
25root  = tk.Tk()
26
27e = tk.Entry(root)
28e.pack()
29e.insert('end', 'https://stackoverflow.com')
30
31b = tk.Button(root, text='Selenium Open', command=on_open)
32b.pack()
33
34b = tk.Button(root, text='Selenium Close', command=on_close)
35b.pack()
36
37root.mainloop()