0

I'm trying to upload a file to the following website: kapwing.com/subtitles

I have:

driver=webdriver.Chrome()
driver.get("https://www.kapwing.com/subtitles")

pageSource = driver.page_source
splitted = pageSource.split(" ")
variable = splitted[2119]
final_variable = variable.split('"')[1]
time.sleep(5)
print(final_variable)
driver.find_element_by_id(final_variable).send_keys("/Users/xx/Desktop/lol.mp4")

but it says ID cannot be found. I would appreciate any help.

2
  • Are you trying to type into the text box to the right of upload file where it asks for a url? Commented Sep 30, 2021 at 2:40
  • @Lzypenguin I'm just trying to upload from computer. but either can work.. Commented Sep 30, 2021 at 3:09

4 Answers 4

1

If you are trying to click on the upload button and then type out the location to your file in the popup, you are not going to be able to locate the textbox in the popup till you click it.

you could use this:

import keyboard

upload_button = driver.find_element_by_xpath('//*[@id="upload-button-input-887ef963-27c3-46cc-8de5-dec5fc340dd7"]')
upload_button.click()

time.sleep(5)

keyboard.write('/Users/xx/Desktop/lol.mp4')
keyboard.press_and_release('return')
Sign up to request clarification or add additional context in comments.

1 Comment

It errors out by saying the ID doesn't exist. I believe it's because it's dynamic? "Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="upload-button-input-887ef963-27c3-46cc-8de5-dec5fc340dd7"]"}"
0

The webpage has input[type='file'] input field that means you can directly do .send_keys

time.sleep(5)
driver.find_element_by_css_selector(input[type='file']).send_keys("/Users/xx/Desktop/lol.mp4")

PS time.sleep(5) is just for visibility purpose. You can remove that as well.

Comments

0

Try this one should work for you:

element = driver.find_element_by_xpath("//*[@id='upload-button-input-41d31461-54e1-47a3-978b-82b3077fe73e']")
element.send_keys("/Users/xx/Desktop/lol.mp4")

Comments

0

sendKeys function works for input tag. You need to find the element and send the location of file.

element = driver.find_element_by_xpath("//input[contains(@id,'upload-button-input')]")
element.send_keys("location of file.")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.