0

There is a website where i gotta press a button and then upload a pic. When I press the button, my personal library will appear, and I will then have to choose the path for my picture.

Here is my code I tried:

from selenium.webdriver.common.keys import Keys
from selenium import webdriver
from time import sleep

upload = browser.find_element_by_id('uploadButton')
upload.click()
upload.send_keys('C:\\Users\\sebastian\\Desktop\\pictures\\1757.jpg')
upload.send_keys(Keys.ENTER)

Here is my problem: It goes into my library pastes the path to my picture perfectly. But then! Its like it doesnt press enter, or maybe it cant accept an enter? I dont know. But it just stays there. And no error appeares on the output.

Sebastian Nielsen
  • 3,143
  • 4
  • 19
  • 35
  • Possible duplicate of [How to upload file ( picture ) with selenium, python](http://stackoverflow.com/questions/8665072/how-to-upload-file-picture-with-selenium-python) – Falloutcoder Nov 14 '16 at 19:55

1 Answers1

2

Seems like a typo mistake. its send_keys not sendKeys. Correct it to upload.send_keys(Keys.ENTER)

Falloutcoder
  • 996
  • 6
  • 19
  • see here is the result: https://gyazo.com/d2db4fdc9602008be666b08a690c2467 It sends the keys to the folde and the picture, but for some reason it doesnt "press enter" and leave it. PS. Yes i also tried upload.send_keys(Keys.ENTER) -the blue button is the button I press to upload a button (its in my language) – Sebastian Nielsen Nov 14 '16 at 19:46
  • Well its a native upload dialog. For this purpose you can look at this answer to get a clear picture http://stackoverflow.com/questions/8665072/how-to-upload-file-picture-with-selenium-python?answertab=active#tab-top – Falloutcoder Nov 14 '16 at 19:52