Reputation: 151
I'm trying to fill this form to improve my job, i tried with Selenium but something goes wrong:
driver= webdriver.Chrome('/Users/48604/Desktop/kyk/chromedriver')
driver.get('https://quintadb.com/widgets/cCsqTdWRnaWPBdGb4zgCkg/c_mw7dRmneW4mgWQzrFdOq')
fill = driver.find_element_by_xpath("//input[@name='dtype[cTqIlcPGbjsk_cIuZdPSoQ]' and @id='dtype_cTqIlcPGbjsk_cIuZdPSoQ']").click()
fill.send_keys('test')
but i am getting error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@name='dtype[cTqIlcPGbjsk_cIuZdPSoQ]' and @id='dtype_cTqIlcPGbjsk_cIuZdPSoQ']"}
I tried as well:
fill = driver.find_element_by_xpath("//input[@name='dtype[cTqIlcPGbjsk_cIuZdPSoQ]' and @id='dtype_cTqIlcPGbjsk_cIuZdPSoQ']").click()[0]
but still not working, any idea?
Upvotes: 0
Views: 908
Reputation: 5531
Bring .click()
to the next line:
fill = driver.find_element_by_xpath("//input[@name='dtype[cTqIlcPGbjsk_cIuZdPSoQ]' and @id='dtype_cTqIlcPGbjsk_cIuZdPSoQ']")
fill.click()
fill.send_keys('test')
Output:
Your code didn't work because you have assigned the output of the .click()
function to the variable fill
. When you print out the type of fill in your code, this is what it prints:
fill = driver.find_element_by_xpath("//input[@name='dtype[cTqIlcPGbjsk_cIuZdPSoQ]' and @id='dtype_cTqIlcPGbjsk_cIuZdPSoQ']").click()
print(type(fill))
Output:
<class 'NoneType'>
And a variable of type NoneType
does not have a function called .send_keys()
. Hence, your code didn't work.
Upvotes: 1