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
2,318 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
• 28,000 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
1,513 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,520 points
4,590 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,010 points
5,459 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,890 points
3,285 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 2, 2020 in Selenium by Sri
• 3,010 points
3,866 views
0 votes
1 answer