I want to upload a .apk file to Kaspersky's online scanner by using selenium and Python. However, the file is interpreted as a URL when I use selenium's send_keys() method.
The relevant HTML looks like this:
<div class="container">
<div class="div-field-home">
<div class="div-hero-scanner-wrapper">
<!-- ======= -->
<div class="acenter pdv-1x" id="drop-area">
<form action="" id="SendForm">
<div class="d-inline">
<div class="tags-inline amiddle file-load-group">
<input id="txt-input-01" type="text" class="small" placeholder="Drag-and-drop a file or paste a link here" maxlength="2000" txtvalue="">
<a href="#" class="d-inline bt-attach bt-attach-file"><img src="/resources/img/attach.png" class="w-100" alt=""><img src="/resources/img/attach_inactive.png" class="w-100" alt=""></a>
<a href="#" class="btn upper small bt-attach-res bt-attach-file">Attach file</a>
<a href="#" class="btn upper clr-ff bg-02 small bt-check bt-disable" analytics-event="StartScan.Click">Scan</a>
</div>
Code:
kaspersky_base_URL = "https://virusdesk.kaspersky.com/#"
driver = webdriver.Firefox()
driver.get(kaspersky_base_URL)
file = "/home/user/filepath"
driver.implicitly_wait(30)
input = driver.find_element_by_id("txt-input-01")
input.send_keys(file)
driver.implicitly_wait(60)
links = driver.find_elements_by_xpath('//a[contains(@href, "#")]')
for elem in links:
if 'SCAN' in elem.text:
elem.click()
I have also tried to change the input type=text
to type=file
. It is changed, but the same error keeps occurring.
I think that the problem might be that one has to click on the file attack link for the text to be interpreted as a file. But not completely sure.
Any help would be appreciated!