I have been looking around for quite some time to find a solution to my problem, I hope that someone can think of something that could help.
I have a working selenium script (in Python) that works with the Firefox driver to connect to a website. When using PhantomJS as a driver, it no longer works.
The form is created by javascript and is located on the https website. Here is the user input code:
<script language="JavaScript1.2"> document.writeln("<input class=\"textform\" type=\"text\" id=\"user\" name=\"user\" size=\"" + size + "\" tabindex=1 onFocus=\"hadFocus(true)\">"); </script>
Here is the part of the script that is looking for it: (works on firefox, but not PhantomJS)
from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import time driver = webdriver.Firefox() driver.get([MY URL]) print driver.page_source driver.find_element_by_id("user").clear() driver.find_element_by_id("user").send_keys([MY USER ID]) driver.find_element_by_id("pass").clear() driver.find_element_by_id("pass").send_keys([MY PASS]) driver.find_element_by_name("login_btn").click() html_source = driver.page_source print html_source driver.close()
And here is the error I get:
selenium.common.exceptions.NoSuchElementException
If I print page_source immediately after reaching the page, Firefox shows the correct source code, where PhantomJS has only: <html><head></head><body></body></html>
Are you thinking of anything that might be causing this?
source share