Home  >  Q&A  >  body text

python - 如何使用selenium上传本地文档到百度上

场景是这样的:
1,先登录百度
2,点击上传本地文件

实际场景是点击上传本地文件的按钮后才会出现选定文件的框框

我根据实际场景写了这几行代码:

window=driver.find_element_by_xpath(".//[@id='WKFlashUploader']/embed").click() //点击上传文件按钮
window.send_keys("C:UsersliliDesktopbaidu.txt")//

报了这样的错误

教程是这样的:


哪里不对劲呢

ringa_leeringa_lee2762 days ago542

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 10:31:38

    .After click(), the window is the return result of the click() method. If there is no return, the window is None and cannot send_keys

    reply
    0
  • 阿神

    阿神2017-04-18 10:31:38

    File upload has been implemented through win32gui

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:31:38

    I use the key wizard, you can also use win32gui

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 10:31:38

    First check the window handle to be empty. If it is empty, it will not be processed

    reply
    0
  • Cancelreply