Search code examples
linuxseleniummalformedurlexception

Malformed url exception linux local file system


I have been trying to execute a selenium.attachFile command to upload a file-

sel.attachFile(dom_locator,"/home/xyz/Desktop/tstfl.txt");

but getting a Malformed URL Exception for the file path specified. The file is present in the linux local file system. Please help me with the proper format of the file path.


Solution

  • Likely what you need is

    sel.attachFile(dom_locator,"file:///home/xyz/Desktop/tstfl.txt");
    

    For an explanation of file uris, see File URI scheme in wikipedia.