Python Selenium Unable to find field element to send _keys

238 views Asked by At

Overlay or FrameI am trying to use Python code in order to update my Discogs with tracking numbers in the specific field when I ship an item.

When I inspect that field box , this is the code (which is also shown in my attachment)

input type="text" class="full_width push_down_mini" style="margin-right:0;" placeholder="Tracking number (optional)" data-reactid=".0.$=1$react-modal-overlay.$react-modal.3.0.3"

I have been good with using driver.find_element_by_ID Text and Name to navigate. But can't find out what to use to get this field box element to be located so I can then use search.send_keys. I have tried xpath & class but no luck error comes back with unable to find element.

Screenshot of Discogs field and code

1

There are 1 answers

7
frianH On

The input field having multiple class name, namely full_width and push_down_mini. So css selector I think is the best approach.

In this case you can't use .find_element_by_class_name, because this is just for single class name.

#UPDATE

Try the below code, use .find_element_by_css_selector:

#update here
driver.switch_to.frame(driver.find_element_by_id('onetrustIabCookie'))

search = driver.find_element_by_css_selector('input.full_width.push_down_mini')
search.send_keys('your key')

Or with .find_element_by_xpath:

search = driver.find_element_by_xpath('//input[@class="full_width push_down_mini" and contains(@placeholder, "Tracking number")]')
search.send_keys('your key')