我正在运行在 Firefox 中运行良好的 selenium 测试,但在使用 PhantomJS 时出现错误。
这是我的python代码:
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")
这是我得到的错误:
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
它无法找到 element id_name
,但是当与 FireFox 一起运行时,效果很好。
任何人都知道 PhantomJS 是否存在解决此问题的当前错误?
目前在 Ubuntu 12.04 上使用 Selenium 2.35.0 和 PhantomJS 1.9.2