0

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

JayBoj
  • 1
  • 1

1 Answers1

0

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')
frianH
  • 7,295
  • 6
  • 20
  • 45
  • Hello when trying find_element_by_css_selector, i get this error in return : selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document (Session info: chrome=83.0.4103.61) . As for xpath error: Message: no such element: Unable to locate element: – JayBoj Jun 11 '20 at 15:59
  • @JayBoj is there ` – frianH Jun 11 '20 at 17:25
  • Hello, well the page I am reference requires a "seller" to log in so if you dont use Discogs i will be tough to replicate the envrionment. However the URL is this https://www.discogs.com/sell/order/1401942-1884 where 1401942-1884 is specific to the seller & order number, so that can always change. However what I do notice when clicking Mark As shipped and you get the window I put in the attachment with field the URL doesnt change.It seems there is an "over lay" or working within a frame.my attachment link ended up right at the beginning of my post ("overlay or frame") – JayBoj Jun 11 '20 at 21:48
  • Yes there are, the one that is above the field element is : – JayBoj Jun 11 '20 at 21:59
  • And also under that iframe there is a div class react-modal status-change-modal , which identifies that whole box (which contains the field I want to input the keys / text) – JayBoj Jun 11 '20 at 22:02
  • @JayBoj see the above updated answer, if inside ` – frianH Jun 12 '20 at 05:16
  • @JayBoj and please don't post as image, copy the HTML and paste in the question. – frianH Jun 12 '20 at 05:18