Ad

Uploading A File To Shopify With Selenium And Python

- 1 answer

I am having difficulty uploading files to shopify using selenium .. Selenium can't seem to find the input element I need to add my file to, I'm assuming it's to do with the input type=hidden part? See image.

enter image description here

I have tried a bunch of variations like this

WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='files_']"))).send_keys("DIR/myfile.pdf')

and tried to execute a scrip to try unhide the input

container = browser.find_element_by_xpath("//input[@type='hidden']")
browser.execute_script("arguments[0].type = 'text';", container)

etc etc

The documentations for shopifyapi aren't the greatest, and I'm not the best coder. Any help woul dbe apprecitated. Thanks!

Ad

Answer

To upload file you have to send keys to the input with type file, generally it hidden. Replace element_to_be_clickable with presence_of_element_located and try to send keys like in code below:

WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input#files_"))).send_keys("DIR/myfile.pdf')
Ad
source: stackoverflow.com
Ad