Search code examples
robotframeworkselenium2library

Not able to upload a .jpg image using Robot Framework


I am trying to upload a .jpg file in web page using Choose file | Locator | File Path command. But it just opens the Windows folder, not navigating to the File Path which I've given.

*** Settings ***
Library           SeleniumLibrary

*** Variables ***
${Home_Page_URL}    https://34.239.9.24:8443/LIVMOR/
${FilePath}       C:\\Users\\20073018\\Desktop\\Pranesh_Kulkarni.jpg

*** Test Cases ***
.
.
TC9-Change Profile Picture
    Click Element    xpath=//a[@onclick="openAttachment()"]
    Choose File      xpath=//a[@onclick="openAttachment()"]    ${FilePath}

Solution

  • You should not be clicking on an element that opens a file chooser. Instead, you call choose file on the input element that is used to pass the filename to the server. The whole point of choose file is to avoid the popup dialog, since selenium can't control the dialog.