0
votes

I need to upload a file using 'upload' button. after that a window will appear but I can't find the exact ID from HTML code. here is the screen shots and my code: enter image description here

enter image description here

`time.sleep(1) element=driver.find_element_by_id("Upload-Action-Ico").click()

driver.find_element_by_xpath("//*[contains(text(), 'File')]").send_keys("file path")`

4
Could you maybe give us the URL of the website? - Oliver Hnat
It is a local website and will open only with specific ip's. here is the HTML code of this web site pastebin.pl/view/c0c3e73e - Aref Farzaneh
@aref Check out my answer and let me know whether it works for u. - Sushil

4 Answers

0
votes

I think that the ID is 'file' so I think this should work

time.sleep(1) 
element=driver.find_element_by_id("file").click()
0
votes

Try click on it and show the HTML code. There is a word "Button" or similar. Can you share me the url of the site? I hope I can help you and excuse me for my english. (It isn't my mother-language)

0
votes

The input field does not contain any text. And its id is explicitly mentioned in the html, so you can try find_element_by_id:

driver.find_element_by_id("file").send_keys("file path")

If this doesn't work for you, then you can try using the xpath:

driver.find_element_by_xpath("//*[@id='file']").send_keys("file path")
0
votes

You can use this code to select files, and after that, you should click on the upload button.

filePath = os.getcwd()+'\img.jpg'
driver.find_element_by_id('Upload-Action-Ico').send_keys(filePath)

os.getcwd() : returns the current working directory. img.jpg is located right next to the running script in the same directory.