Search code examples
seleniumselenium-chromedriversendkeys

Autofill with python


I'm trying to build a bot with python. I want python to act as an autofill and I made this part of programm :

> ord_billing_name=driver.find_element_by_xpath('//*[@id="cart- 
address"]/fieldset/div[1]').click()
> ord_billing_name.send_keys(buyerName)

(The programm to get to the website works)

But python displays :

AttributeError: 'NoneType' object has no attribute 'send_keys'

And the case is not filled on the website. Please, can someone tell me what is wrong ? Thanks a bunch.


Solution

  • .click() doesn't return anything but you are assigning the return to ord_billing_name. You need to separate this into 3 lines... first line is grabbing the element and assigning it to the variable. The other two lines are click() and send_keys().

    ord_billing_name = driver.find_element_by_xpath('//*[@id="cart-address"]/fieldset/div[1]')
    ord_billing_name.click()
    ord_billing_name.send_keys(buyerName)