有没有一种方法可以在不使用HTML/CSS元素的情况下跟踪Selenium中的上传进度



有没有一种方法可以在不使用HTML/CSS元素的情况下使用Python>Selenium跟踪文件上传的进度?正在寻找一个适用于许多网站的通用解决方案,但不知道从哪里开始。

在Python的请求库中,进度是可以确定的,因为你是以块为单位进行流式传输的,但我不知道在Selenium中从哪里开始,也不知道这是否可能。

尝试在性能日志中查找有关上传进度的信息

# Doesn't work for Firefox. Only Chrome
capabilities = webdriver.DesiredCapabilities().CHROME
capabilities["goog:loggingPrefs"] = {"performance": "ALL"}
driver = webdriver.Chrome(desired_capabilities=capabilities)
# upload file
# watch performance logs
for perf_entry in driver.get_log("performance"):
perf_entry["message"] = json.loads(perf_entry["message"])["message"]
# check perf_entry

相关内容

最新更新