I am using selenium and PhantomJS for testing. I followed Selenium's simple usage, but send_keys doesn't work on PhantomJS, it works on Firefox. Why? I have to use button.click()
instead?
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sysreload(sys)
sys.setdefaultencoding('utf-8')
from selenium import webdriver
from selenium.webdriver.common.keys import Keysdriver = webdriver.PhantomJS()driver.get("http://www.python.org/")
elem = driver.find_element_by_id("q")
elem.clear()
elem.send_keys("python")
elem.send_keys(Keys.RETURN)
# button = driver.find_element_by_id('submit')
# button.click()
print driver.title
print driver.page_source
driver.close()