Firefox -> PhantomJs Login to website not working

99封情书 提交于 2019-12-03 21:55:40

Below code works well for me!

import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

url = 'http://www.neighborhoodscout.com/'
username = 'abc@bcas.fulba.com'#change here
password = '12345'#change here
driver = webdriver.PhantomJS(r"C:\phantomjs.exe")
driver.set_window_size(1124, 850)  
driver.get(url)
time.sleep(2)
login = driver.find_element_by_xpath("//a[@ id='login']")
login.click()
time.sleep(5)
usr = driver.find_element_by_xpath("//input [@id='user_email' and @class='input-text']")
passw = driver.find_element_by_xpath("//input [@id='user_password' and @class='input-text' ]")
logbtn = driver.find_element_by_xpath("//input [@id='login-button' and  @class='btn']")
usr.send_keys(username)
passw.send_keys(password)
logbtn.click()

time.sleep(4)

if '/users/sign_out' in driver.page_source:
    print "Logged In"
driver.close()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!