I’m trying to use Selenium and PhantomJS for headless browsing to login a forum.Below is the code I used using Firefox and then change it to PhantomJS
driver = webdriver.PhantomJS()
base_url = "http://6atxfootball.vbulletin.net/"
verificationErrors = []
accept_next_alert = True
driver.get(base_url)
driver.find_element_by_id("lnkLoginSignupMenu").click()
driver.find_element_by_id("idLoginUserName").clear()
driver.find_element_by_id("idLoginUserName").send_keys("USERNAME_HERE")
driver.find_element_by_id("idLoginPassword").clear()
driver.find_element_by_id("idLoginPassword").send_keys("PASSWORD_HERE ")
driver.find_element_by_id("idLoginBtn").click()
It shows an error is “NoSuchElementException:”.
driver.find_element_by_id("idLoginUserName").clear()
does this mean there’s no such an element when it’s opened by PhantomJS()?
I also tried to save the content also by PhantomJS() as a file and see what’s happening:
driver = webdriver.PhantomJS()
base_url = "http://6atxfootball.vbulletin.net/"
verificationErrors = []
accept_next_alert = True
driver.get(base_url)
content=driver.page_source
cleaner=clean.Cleaner()
content=cleaner.clean_html(content)
with open('6atxfootball.html','w') as f:
f.write(content.encode('utf-8'))
doc=LH.fromstring(content)
the “6atxfootball.html” shows there isn’t any form to fill.