0

I want to use Python to press the left mouse button at a button of a website. My code I'm trying:

from TKinter import *
import webbrowser

def blackdesertonline():
    webbrowser.open("http://black.game.daum.net/black/index.daum",
        new=1,
        autoraise=True)

main = Tk()

bblackdesertonline = Button(main,
    text = "Start Black Desert Online",
    command = blackdesertonline)

bblackdesertonline.pack()

main.mainloop()

How can I tell the program to press a button?

hexerei software
  • 3,100
  • 2
  • 15
  • 19
CR0WN3
  • 1
  • 3
  • Tangentially related: [mechanize python click a button](http://stackoverflow.com/q/1806238/953482). I get the feeling that the answer applies to `webbrowser` too. – Kevin Apr 09 '15 at 16:23
  • do you want to press the button you created on the TK view? or do you want to press the button on the webpage opened? – hexerei software Apr 09 '15 at 16:28
  • I want to press a button on the webpage. The page contains the button "Game Start" and I want that when I press the button "Start Black Desert Online" the program should go to the website AND press the button "Game Start". But sadly I have no idea how – CR0WN3 Apr 09 '15 at 16:30

1 Answers1

1

You will need to use a library specifically designed to automate websites, such as selenium.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • i had perfect results with selenium and triggering a button press on the website is incredibly easy. i.e. just find element by id or name (`elem = browser.find_element_by_id("id_of_button")`) and then use the `elem.send_keys(Keys.RETURN)` function to activate button – hexerei software Apr 09 '15 at 22:33