简体   繁体   中英

WebDriverException: Message: File not found - Close Upload FIle window in Robot Framework

I need to close the File Upload window of a browser. I tried the following code to achieve this

Press Key id=fileToUpload \\\\27 - I found the ascii character in the URL http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000520.html

My Complete code is

*** Variables ***
${TVAURL}     http://localhost:1500/
${Browser}    Firefox

TC_01: Enter into the application
    [Documentation]   Enter into the application to upload a file
    Open Browser   ${TVAURL}     ${Browser}
    Choose File    id=fileToUpload    C://Downloads/Demo/rose.png
    Press Key    id=fileToUpload    \\27

My respective sample HTML code is

 <!DOCTYPE html> <html> <head> <title>Upload File</title> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <br/> <input type="submit" value="Upload Image" name="submit"> </form> </body> </html> 

It gives the error message WebDriverException: Message: File not found : //27

在此处输入图片说明

I need to close the file uploader window of a browser, once the file gets uploaded (ie, next to the Choose File command)

在此处输入图片说明

Once you upload the file you need to click the submit button on the website and not uploadfile again with the wrong locator..

<input type="submit" value="Upload Image" name="submit">

Change your last line from:

Press Key id=fileToUpload
to

Press Key name=submit

That should do it for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM