0
我想在python中使用selenium自動上傳文件。我不知道如何使用打開的文件對話框。我不能使用send.keys()
,因爲我的腳本需要在Linux,Windows和Mac OS X上工作。有沒有一種方法可以通過硒或附加數據包來控制它?用selenium和python上傳文件沒有send.keys
我對上傳腳本到目前爲止是:
import selenium
import sys
try:
driver = webdriver.Firefox()
driver.implicitly_wait(5)
driver.get("ip of where im going")
username = driver.find_element_by_id('LogView')
username.send_keys("username")
password = driver.find_element_by_id('passView')
password.send_keys('password')
submit = driver.find_element_by_id('Submit').click()
except:
print "could not connect"
sys.exit()
try:
driver.find_element_by_partial_link_text("settings").click()
# (I can open openfiledialog box from here is i need to)
except:
print "Wrong"