我正在使用Selenium和Python 3进行编码。我当前上传图像的代码是:
driver.find_element_by_xpath('//*[@name="Filedata"]').send_keys("C:/Users/MyName/PycharmProjects/NikeSNKRS/profilepic.jpg")
我想上传图像而不必输入整个路径,但是如果我尝试以下代码;
driver.find_element_by_xpath('//*[@name="Filedata"]').send_keys("profilepic.jpg")
我收到此错误消息:
selenium.common.exceptions.WebDriverException:消息:未知错误:路径不是绝对的:profilepic.jpg (会话信息:chrome = 86.0.4240.183)