button click in python code example
Example 1: how to click on button using python
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('your page url')
button_element = driver.find_element_by_id('button id')
button_element.click()
Example 2: button tkinter
import Tkinter
import tkMessageBox
top = Tkinter.Tk()
def helloCallBack():
tkMessageBox.showinfo( "Hello Python", "Hello World")
B = Tkinter.Button(top, text ="Hello", command = helloCallBack)
B.pack()
top.mainloop()
Example 3: add button python
from tkinter import *
master = Tk()
def closewindow():
exit()
button = Button(master, text="close window", command=closewindow)
button.pack()
mainloop()