看代码:
# coding: utf-8
from selenium import webdriver
from time import sleep
driver = 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)
# 文件的路径
file = r"C:\Users\DELL\Desktop\ldh.jpg"
# 上传文件
driver.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()
?
微信公众号搜索“自动化测试实战”或扫描下方二维码添加关注~~~
时间: 2024-10-10 02:15:27