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

时间秒杀一切 提交于 2020-01-07 03:53:24

问题


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 (i.e., next to the Choose File command)


回答1:


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.



来源:https://stackoverflow.com/questions/44626501/webdriverexception-message-file-not-found-close-upload-file-window-in-robot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!