I'm running selenium tests which work OK in Firefox, but I get an error when using PhantomJS.
Here is my python code:
driver.find_element_by_link_text("Add Province").click()
driver.find_element_by_id("id_name").clear()
driver.find_element_by_id("id_name").send_keys("Frosinone")
driver.find_element_by_id("id_code").clear()
driver.find_element_by_id("id_code").send_keys("FR")
And here is the error I'm getting:
driver.find_element_by_id("id_name").clear()
self._execute(Command.CLEAR_ELEMENT)
return self._parent.execute(command, params)
self.error_handler.check_response(response)
raise exception_class(message, screen, stacktrace)
E InvalidElementStateException: Message: u'Error Message => \'Element is not currently interactable and may not be manipulated\'\n caused by Request => {"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"81","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:38159","User-Agent":"Python-urllib/2.7"},"httpVersion":"1.1","method":"POST","post":"{\\"sessionId\\": \\"e0d4d1b0-2f36-11e3-af69-b579903d9fbd\\", \\"id\\": \\":wdc:1381139859399\\"}","url":"/clear","urlParsed":{"anchor":"","query":"","file":"clear","directory":"/","path":"/clear","relative":"/clear","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/clear","queryKey":{},"chunks":["clear"]},"urlOriginal":"/session/e0d4d1b0-2f36-11e3-af69-b579903d9fbd/element/%3Awdc%3A1381139859399/clear"}' ; Screenshot: available via screen
It is unable to find element id_name
, yet when run with FireFox, works perfectly.
Anyone knows if there is a current bug with PhantomJS that addresses this issue?
Currently using Selenium 2.35.0 and PhantomJS 1.9.2 on Ubuntu 12.04
I've used a PhantomJS, ChromeDriver and FirefoxDriver for functional testing. The difference between PhantomJS and others is that PhantomJS driver don't wait for page to be loaded and returns control to the test program (your python code). Please check this out!
I think this is not a correct behaviour of PhantomJS driver. I found in WebDriver's api documentation: http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#get(java.lang.String) the following method of WebDriver which opens a given URL
void get(java.lang.String url)
The description is:
Load a new web page in the current browser window. This is done (...) and the method will block until the load is complete.
So it is possible that (and here I agree with @Ashley comment)
You can find it easy if you "sleep" your test code for a, let's say, 2 seconds, just before you access first element in your test.
If this is it, you can try to resolve this issue by waiting for page to load (instead of 2 seconds) by checking some condition on your page, e.g. page title should be "My Form". Try it in loop until condition is true. Then run rest of your test.
Note: You can always take a screenshots, also in headless PhantomJS driver implementation! It will give you a possibility to debug a problem
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