So I have page structured like this :
<ul>
<li>
<div>
<div>
<span class="buttonUpload" custom="call.js">Button Upload</span>
<input class="fa-cloud-upload" name="file" type="file" accept="">
</div>
</div>
</li>
<li>
<div>
<div>
<span class="buttonUpload" custom="call.js">Button Upload</span>
<input class="fa-cloud-upload" name="file" type="file" accept="">
</div>
</div>
</li>
<li>
<div>
<div>
<span class="buttonUpload" custom="call.js">Button Upload</span>
<input class="fa-cloud-upload" name="file" type="file" accept="">
</div>
</div>
</li>
</ul>
I want to upload file only to the first input tag using send_keys()
from selenium but for some reason it's not working, if there's only single li tags shown after refresh then the codes work, my code as bellow :
view_videos = WebDriverWait(driver, self.latency).until(EC.visibility_of_all_elements_located(
(By.CSS_SELECTOR, "a[i18n='i18n.openLink']")))
for i in range(len(view_videos)):
# some other script here
uploadme = "/home/user/myfile.png"
#script to upload
driver.find_element_by_css_selector("input[class='fa-cloud-upload']").send_keys(str(uploadme))
I even try with driver wait and select all element with selected array:
#script to upload
upload_first = WebDriverWait(driver, self.latency).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "input[class='fa-cloud-upload']")))
upload_first[0].send_keys(str(uploadme))
But nothing happened, I execute also javascript to erase 2 <li>
tags after the first one before upload but still upload not working, nothing happens, I just want to upload to first input only using selenium, any clue?