Uploading Multiple Files with Selenium using Python

I have been working on a multiple image upload feature and here is the code I am using:

import selenium
import time
import selenium.common.exceptions
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.action_chains import ActionChains

# Set file path for Chromedriver
chromedriver = "C:/Users/chromedriver_win32/chromedriver"
driver = webdriver.Chrome(chromedriver)
driver.get("https://url.com")

# Log in to the website
driver.find_element_by_id('ctrlLogin_UserName').send_keys("xyz.com")
driver.find_element_by_id('ctrlLogin_Password').send_keys("abc@01")
driver.find_element_by_id('ctrlLogin_LoginButton').click()

# Allow time for all objects to load
time.sleep(5)
driver.maximize_window()

# Click on Reports tab
driver.find_element_by_xpath('full XPath').click()

# Navigate to New Reports
driver.switch_to.frame("hostFrame")
driver.find_element_by_xpath('full XPath').click()

# Allow for Reports to load
time.sleep(5)
driver.switch_to.default_content()

# Open Report folder
time.sleep(5)
driver.switch_to.frame("hostFrame")
driver.find_element_by_xpath('full XPath').click()

time.sleep(5)
driver.execute_script("window.scrollTo(0, 600);")
driver.find_element_by_xpath('full XPath').click()

time.sleep(2)

driver.find_element_by_xpath('full XPath').click()

uploader = driver.find_element_by_xpath('full XPath')
uploader.send_keys("C:/Users/blabla.jpg")

However, I encountered an error message stating:

raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (Session info: chrome=87.0.4280.88)

I attempted to add a wait function but it did not resolve the issue. Any suggestions or ideas would be greatly appreciated.

Answer №1

It appears that the element is currently not interactable due to either its visibility or being obstructed by another element. Please ensure that the element is in a state where it can be interacted with and visible, and also verify that you are using the correct locator for it. Attempt to make the following changes:

uploader.send_keys("C:\\Users\\example.jpg")

and :

scro=driver.find_element_by_xpath('full XPath')
scro.location_once_scrolled_into_view
scro.click()

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A ModelSerializer that is nested within another ModelSerializer

I'm currently working on setting up a nested JSON file in Django Rest Framework. I've been researching different approaches to properly nest my serializers, but haven't had much success. I'm struggling with creating a model serializer ...

Python goes unnoticed as the days go by

Python 3.9 was working perfectly for me until I tried to use the wordcloud module, only to realize it wasn't compatible with that version. So I decided to install Python 3.8, but after uninstalling 3.9, nothing seems to be working. Every time I attem ...

Integrate PySide with PyGame for a more dynamic and interactive

Are you interested in creating a user interface that includes forms for app configuration and a rendering component, such as displaying sprites? Is there a way to integrate PySide with PyGame within a single application? For instance, how would one go abo ...

Understanding how to implement a color map on an image through cv2.LUT

As a beginner with opencv, I am encountering an issue. I have a np.array color and I would like to incorporate it into my image Here is the np.array color that I intend to add turbo_colormap_data = np.array( [[0.18995,0.07176,0.23217], [0.19483,0 ...

Is it possible for Webdriver to match the speed of Selenium IDE?

I have been working on a unique test runner that allows me to run Selenium tests in TeamCity. One of the latest features I added is the ability to create tests in the IDE and save them in HTML format, which can then be executed by the test runner using Pyt ...

A Fresh Approach to Altering Dictionary Organization

In Python, I am working with an object type that contains multiple entries in the data-object. An example entry is shown below: > G1 \ jobname x [3. ...

Having trouble with closing the login window or accessing the HomePage on makeMyTrip.com

As I attempt to automate the MakeMyTrip website using selenium, a snag I've encountered is that the login window ends up blocking all other elements on the page when running tests. One approach I took was trying to click elsewhere on the page in an e ...

Encountering difficulties inputting text in email body on Selenium using Java

I am trying to implement a function that sends emails using Gmail, but I am facing an issue where the code only sends emails with empty bodies. I suspect that the frame switch is not done correctly. Can someone please guide me on which frame is used for co ...

What contributes to the superior performance of pickle + gzip compared to h5py when working with repetitive datasets?

I have encountered an issue while saving a numpy array that contains repetitive data: import numpy as np import gzip import cPickle as pkl import h5py a = np.random.randn(100000, 10) b = np.hstack( [a[cnt:a.shape[0]-10+cnt+1] for cnt in range(10)] ) f_p ...

Troubles encountered when trying to save an Excel.Writer document to a different directory

A timed backup system is being developed for an Excel document using Python, since there will be multiple users accessing it. The goal is to alter the file path away from the local directory. Below is the code snippet; import pandas as pd import datetime ...

Is there a way to automatically start a process during system boot at runlevel 2 using code?

Can someone please help me figure out how to write Python code that will initiate a process during startup, specifically at level two? I've done some research on my own, but I'm still unsure about the most reliable method to use across different ...

Include a label above every point on the line graph displaying its corresponding value using Python

I have a situation where I am working with a bar and line graph each plotted on different y-axes. One specific requirement I have is to label the line graph with its values positioned just above each point on the line. To achieve this, I experimented with ...

Automate the process of logging into Tenable.io by utilizing Selenium with Python

Greetings! I am fairly new to the world of programming and have been encountering an issue while trying to automate credential input on using Selenium with Python. Despite my attempts at research, I have not been able to find a solution thus far. Please f ...

Dealing with Chrome pop ups in Java Selenium with the ChromeDriver: Tips to deny or block them

I'm encountering an issue where every time my program attempts to visit a specific website, Chrome displays a pop-up asking for permission to continue in an app that I do not wish to install. I want to either deny this permission or completely block i ...

Utilize the second browser that is currently open for better productivity

Just started using selenium and faced with an issue. I am currently dealing with a form where clicking "Report" opens a new browser window displaying some data. I need to interact with this data. How can I retrieve and validate the displayed information? ...

Creating anchor tags with href attribute around a specific substring within a string using Django

Presently, I am utilizing regex to locate a specific substring within a given string and then wrapping it in anchor tags with an href attribute within a jinja template. pattern = re.compile(rf"({substring})",re.IGNORECASE); anchoredString = mark_safe(re.s ...

Scraping a JavaScript page using Python without requiring a browser installation

Currently, I am facing a challenge in scraping an HTML element from a webpage. The content within this element is dynamically generated by Javascript, making it impossible to retrieve using a simple requests.GET: response = requests.get(url). While explor ...

Why is my Selenium program consistently throwing a NoSuchElementException regardless of the type of element query I try?

Looking for a solution to an issue with my Selenium code. I am attempting to extract data from a stock data website but keep encountering a NoSuchElementException. When using a JS query in the Chrome developer console, everything works fine: document.getE ...

Discover the expert method for navigating through a specific div, targeting a particular element, and enabling it to be interacted with using the Selenium

https://i.stack.imgur.com/NqBLi.pngMy challenge is to click on a button labeled 'NEW'. While the button is visible in the DOM, it remains unclickable due to being overlapped. To resolve this issue, I need to scroll down on the left side of the pa ...

Halting the execution of Python processes initiated by a subprocess through user input without terminating the subprocess

Currently, I am in the process of developing a Python shell project that requires the capability to pause and background a running subprocess. Unfortunately, I have encountered difficulties with existing methods for pausing the subprocess, as they seem to ...