Reputation: 23135
Can someone tell me how can I upload a file using the Upload button in a website?
HTML Source for upload button
<div id="upload-import-link" class="qq-upload-button string-file-import" style="position: relative; overflow: hidden; direction: ltr;">
<input type="file" multiple="multiple" name="file" style="position: absolute; right: 0pt; top: 0pt; font-family: Arial; font-size: 118px; margin: 0pt; padding: 0pt; cursor: pointer; opacity: 0;">
This is the Upload button behavior.
When I click 'Upload' button, the pop-up window opens to select the file.
As soon as I select the file, it gets uploaded.
How do I automate this behavior?
Upvotes: 0
Views: 513
Reputation: 8548
On the basis of the tags and language selection (perl) I am assuming you are using Selenium 1 RC - Perl
If that is the case you could do it this way
$sel->type_ok("upload-import-link", "\/home\/yourname\/Desktop\/filename.doc",'User enters the file path of the document to be uploaded');
$sel->click_ok("submit","user clicks on upload\/submit button");
Upvotes: 1