1

I'm trying to upload photo using webdriver.Firefox in python:

upload_img_first = '/home/emin/Desktop/test/me.jpg'

driver.find_element_by_xpath('//button[contains(@class, "button-class")]').send_keys(os.getcwd()+upload_img_first)

Red bar appears in browser bottom with image address, /home/emin/Desktop/test/me.jpg

What is wrong?

1
  • What does the html on the page look like? It seems strange that you want to type characters in a button element. Can you supply the page source , at least for the target element. Commented Jan 14, 2014 at 3:25

1 Answer 1

1

Assuming send_keys is being sent to the proper element, it loos like the upload_image_first variable is an absolute path. When you send_keys, you are concatenating the current path to that absolute path.

So, if you run this program from /home/emin, you would send_keys to /home/emin/home/emin/Desktop/test/me.jpg

Sign up to request clarification or add additional context in comments.

1 Comment

I forgot that path in Mac is not same as in Linux, already fixed that problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.