Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
706 views
in Technique[技术] by (71.8m points)

testing - How to upload file ( picture ) with selenium, python

How to upload a picture on a web application with the selenium testing tool? I am using python.

I tried many things, but nothing worked.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What I'm doing is this (make sure drv is an instance of webdriver):

drv.find_element_by_id("IdOfInputTypeFile").send_keys(os.getcwd()+"/image.png")

and then find your submit button and click it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...