python - InvalidElementStateException while running Selenium Webdriver with PhantomJS -


i'm running selenium tests work ok in firefox, error when using phantomjs.

here 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 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 not interactable , may not manipulated\'\n caused 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 unable find element id_name, yet when run firefox, works perfectly.

anyone knows if there current bug phantomjs addresses issue?

currently using selenium 2.35.0 , phantomjs 1.9.2 on ubuntu 12.04

i've used phantomjs, chromedriver , firefoxdriver functional testing. the difference between phantomjs , others phantomjs driver don't wait page loaded , returns control test program (your python code). please check out!

i think not correct behaviour of phantomjs driver. found in webdriver's api documentation: http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/webdriver.html#get(java.lang.string) following method of webdriver opens given url

void get(java.lang.string url) 

the description is:

load new web page in current browser window. done (...) , method block until load complete.

so possible (and here agree @ashley comment)

  • in firefox page rendered before test code tries access element
  • in phantomjs test code tries interact page earlier when not yet ready

you can find easy if "sleep" test code a, let's say, 2 seconds, before access first element in test.

if it, can try resolve issue waiting page load (instead of 2 seconds) checking condition on page, e.g. page title should "my form". try in loop until condition true. run rest of test.

note: can take screenshots, in headless phantomjs driver implementation! give possibility debug problem


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -