I have been looking around for quite a long time now to find a solution to my problem, hope someone here can think of something that could help.
I have a working selenium script (in Python) working with the Firefox driver to connect on a website. When using PhantomJS as driver, it doesn't work anymore.
The form is generated by javascript and is on a https website. Here is the code of the user input :
<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 looking for it : (working 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 the page_source
just after reaching the page, Firefox shows the right source code, where PhantomJS only has : <html><head></head><body></body></html>
Do you think of anything that could be the cause of this ?
I have solved my problem thanks to Artjom B. answer :
Just change in the code :
driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'])
It was due to the ssl certificate I guess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With