Upload file to hidden input using protractor and selenium

后端 未结 2 2032
眼角桃花
眼角桃花 2021-01-20 05:22

I\'ve got a hidden file input field like this:



        
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-20 06:04

    To add on user2355213s answer for the more current releases of protractor. ptor is obsolote and instead browser should be used. Also, executeScript() expects a string as parameter. So I ended up using

    browser.executeScript('$(\'input[type="file"]\').attr("style", "");');
    

    as my visibility setting was directly applied to the element. Of course, you can also use

    browser.executeScript('$(\'input[type="file"]\').removeClass("hidden-uploader");');
    

    depending on your HTML/CSS.

提交回复
热议问题