Not able to upload a file in Selenium Webdriver using python Scripting

0 votes

Not able to perform upload of video file using selenium webdriver. using the code I'm not getting any error but the process gets completed successfully. But, no file gets uploaded.

Can you help me fix it? The only thing I want to do is to attach a *.mp4 file. But as the cursor hovers, i'm unable to find the click or upload file.

Code Used

#1

uploadElement = driver.find_element_by_xpath("//*[text()='UPLOAD ANSWER']")
driver.execute_script("arguments[0].removeAttribute('style')", uploadElement)
uploadElement.sendKeys("/Users/Downloads/samsung_videos/0.mp4")

Below is the HTML CODE for the element.

<button class="ui button" role="button" style="background-color: rgb(31, 186, 238); color: white; border-radius: 0px; padding-left: 40px; padding-right: 40px; font-family: &quot;Open Sans&quot;; font-size: 17px; font-weight: 600; line-height: 20px; text-align: center; width: inherit; height: 50px; margin-top: 26px;">UPLOAD ANSWER</button>
Sep 10, 2019 in Selenium by Srinivas
761 views

1 answer to this question.

0 votes

Hey Srinivas, you can checkout this code snippet to get an idea:

from selenium import webdriver

from selenium.webdriver.common.by import By

from selenium.webdriver.support.ui import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()

driver.get('https://www.example.com')

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//a[@href="/upload/new"]'))).click()

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'browseByComp'))).click()

driver.find_element_by_id('fileUpload_newFileUpload_inputfileUpload').send_keys('/path/to/file')
answered Sep 10, 2019 by Abha
• 27,800 points

Related Questions In Selenium

0 votes
1 answer

How to upload a resume to a website using selenium in python?

Use this code, this will help you: from ...READ MORE

answered Apr 20, 2018 in Selenium by Vardy
• 2,370 points
1,192 views
0 votes
1 answer
+1 vote
2 answers

Is it possible to scroll down in a webpage using selenium webdriver programmed on python?

I using next code for facebook for ...READ MORE

answered May 16, 2019 in Selenium by mslavikas@gmail.com
13,355 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
2,206 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,870 points
1,819 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,870 points
1,809 views
0 votes
1 answer