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
4,196 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.edureka.co')

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
• 28,140 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,360 points
2,882 views
0 votes
1 answer
0 votes
2 answers

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,500 points
13,673 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,142 views
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,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,874 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP