I'd like to fill out a form with
driver.find_element_by_id("name").send_keys("Test")
But I get this error everytime I run the script:
Traceback (most recent call last):
File "fill.py", line 22, in <module>
driver.find_element_by_id("name").send_keys("Test")
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 351, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 955, in find_element
'value': value})['value']
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.
(Session info: chrome=66.0.3359.117)
(Driver info: chromedriver=2.38.552518 (183d19265345f54ce39cbb94cf81ba5f15905011),platform=Mac OS X 10.13.4 x86_64)
<input first_and_last="true" placeholder="name" class="string required" type="text" name="flname" id="name">
Note: I also get an error for searching for the name. If I search for Xpath it fills out the form very slow and I need it to be faster.
How can I solve this problem?
Use either of the locator Strategies :
css_selector :
driver.find_element_by_css_selector("input.string.required#name").send_keys("Test")
xpath :
driver.find_element_by_xpath("//input[@class='string required' and @id='name']").send_keys("Test")
I have tried to lookout for a solution to both of the error messages you were facing and here are the relevant details :
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.
: As per the discussion typeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node Polymer possibly your application is based on Polymer and before you start looking out for any element soon after Page Load as a precautionary measure induce a waiter through WebDriverWait along with proper expected_conditions
Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'."
: As per the discussion JS: Failed to execute 'getComputedStyle' on 'Window': parameter is not of type 'Element' and Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element' error points to the similar behavior that the desired element is not actually present within the DOM while a JavaScript or an Ajax Call is working towards adding/removing elements.