from selenium import webdriveroption = webdriver.ChromeOptions()option.add_argument(‘--user-data-dir=C:/Users/Administrator/AppData\Local/Google/Chrome/User Data‘)driver = webdriver.Chrome(chrome_options=option)driver.get(‘https://www.cnblogs.com/‘)driver.implicitly_wait(10)driver.find_element_by_xpath(‘.//*[@id="user_nav_blog_link"]‘).click()driver.find_element_by_xpath(‘.//*[@class="menu"][5]‘).click()driver.find_element_by_xpath(‘.//img[@alt="上传图片"]‘).click()driver.switch_to.frame(‘mce_39_ifr‘)driver.find_element_by_xpath(‘.//input[@name="file"]‘).send_keys(‘C:\\Users\\Administrator\\Desktop\\5.png‘) 备注:该方法只适用于input标签,其他标签需要借助于第三方工具autoit或者是SendKeys
原文地址:https://www.cnblogs.com/yueyanru/p/9400535.html
时间: 2024-10-25 00:03:53