Look at the code:
# Coding:utf-8 fromSeleniumImportWebdriver fromTimeImportSleepdriver = Webdriver. Firefox () Driver.get ("Https://www.cnblogs.com") Driver.add_cookie ({' name ':'. Cnblogscookie ',' value ':' f956f323dfa5c31be489c0730c7d891 ',' domain ':'. cnblogs.com '}) Driver.add_cookie ({' name ':'. Cnblogs.AspNetCore.Cookies ',' value ':' CFDJ8NJXDYN1379IVW ',' domain ':'. cnblogs.com '}) Sleep (2) Driver.refresh () Driver.find_element_by_xpath (".//*[@id = ' span_userinfo ']/a[1]"). Click () Sleep (3) Driver.find_element_by_xpath (".//*[@id = ' Avatar_opt_nav ']/li[1]/a"). Click () Sleep (2)# Path of the fileFile =r "C:\Users\DELL\Desktop\ldh.jpg"# Upload FilesDriver.find_element_by_xpath (".//*[@id = ' Jquery-wrapped-fine-uploader ']/div/div/input"). Send_keys (file) sleep (3) Driver.find_element_by_xpath (".//*[@id = ' crop_operation_submit ']"). Click ()
?
Public search "automated test Practice" or scan the QR code below to add attention ~ ~ ~
Selenium2 python automation test (13)--Upload file