0

So I'm trying to make a Messenger bot using Selenium and Python. I don't have any code errors my code works just fine, the problem is that after it's done it just kills the WebDriver. Here's my code:

from selenium import webdriver

login_email = "" #Your facebook email login_password = "" #Your facebook password

def login_pulamea():

driver = webdriver.Chrome() driver.get("http://messenger.com") #Waits for page to load driver.implicitly_wait(10) # Inputing email email_box = driver.find_element_by_xpath("""//*[@id="email"]""") email_box.clear() email_box.send_keys(login_email) # Inputing password password_box = driver.find_element_by_xpath("""//*[@id="pass"]""") password_box.clear() password_box.send_keys(login_password) #Submit details submit_button = driver.find_element_by_xpath("""//*[@id="loginbutton"]""") submit_button.click() login_pulamea()
Sami Samp
  • 19
  • 2
  • 7

2 Answers2

1

I have not tried it but I think here is what you could do and I believe this would only work with firefox but that should not be a problem for you as you are not testing any specific browser

  • Launch Browser outside of your script, so when you your scripts exit your browser remain up. Alternatively you could give a try to solution mentioned here
  • Connect to that existing browser using PersistentWebdriver class.

An extra note is latest selenium driver works well with Firefox 45. It has know crash issues with Firefox 47 so make sure you stick to version 45.

Community
  • 1
  • 1
saurabh baid
  • 1,819
  • 1
  • 14
  • 26
  • Check your selenium and firefox version. Firefox 47 will not work, with latest version of selenium (2.53.5). So install version 45 and disable automatic update. – saurabh baid Jun 25 '16 at 16:49
0

Put a breakpoint on the last line of code you want executed before it stops and then run it in debug mode (this will vary depending on your IDE). Once it pauses, you can kill the run and take over the browser or whatever else you want to do.

JeffC
  • 22,180
  • 5
  • 32
  • 55