我有一个显示为 None 的文件字段,我想使用 selenium python 绑定(bind)将文件上传到其中
我尝试了这个,但它不起作用
driver.find_element_by_id("IdOfInputTypeFile").send_keys(os.getcwd()+"/image.png")
最佳答案
driver.execute_script("document.getElementById('id_cv_upload').style.display='block';")
尝试这个基本上 execute_script
是 python 运行 javascript 的命令,因为没有 pythonic 方式来处理 css,所以你必须执行 javascript 来做到这一点。
关于python - 上传字段样式显示为 None 的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12190515/