Multiple files upload in selenium webdiver

后端 未结 4 2057
鱼传尺愫
鱼传尺愫 2021-01-15 23:50

I want to upload 5 files,but my \'file input\' is same name/id,how can i possible to upload five files. My HTML code is:

4条回答
  •  攒了一身酷
    2021-01-16 00:12

    that easy like //input[@type="file"] will point to the first input tag and (//input[@type="file"])[{INDEX}] where INDEX is the number of the of the input tag note: indexing in xpath starts from 1

    OR you can use the

    file_tag_list =driver.find_elements_by_xpath(//input[@type="file"])
    

    function that the python syntax you can find it for different languages just google it. this function will return a list of webdriver element and then you can

    file_tag_list[0].send_keys(filepath)
    file_tag_list[1].send_keys(filepath)
    

提交回复
热议问题