# disable the file picker driver.execute_script(""" HTMLInputElement.prototype.click = function () { if (this.type !== 'file') { HTMLElement.prototype.click.call(this); } else if (!this.parentNode) { this.style.display = 'none'; this.ownerDocument.documentElement.appendChild(this); this.addEventListener('change', () => this.remove()); } } """) # perform the click driver.find_element_by_xpath('//button[normalize-space()="Upload"]')\ .click() # assign the file to the <input type="file"> driver.find_element_by_css_selector('input[type=file]')\ .send_keys(r'c:/myimage.png')