views:

33

answers:

1

String fileLocator here is actually a file URL. I define a file URL to 'file:///D:/images/pic1.jpg' but selenium for some reason i don't get tries to load it from c:\Temp (where the TEMP variable difined dir is located for my user) adding this sequence to the original location, so java returns an exception.

com.thoughtworks.selenium.SeleniumException: java.io.FileNotFoundException: C:\Temp\D:\images\pic1.jpg (Syntax error in filename)

That is rather predictable.

So the question is how to make selenium load file directly from the dir i specify or pass it an URL it will not rewrite?

UPD

Looks like this thing just can't for some reason add files from local file system using 'file' protocol. If i use 'http' it works ok.

A: 

The reason why selenium tries to open your file form C:\Temp is because if you would have provided the a remote file it would have been downloaded there and after that referenced the local copy.

You could try something like this in order to see that indeed the url is correctly defined:

File file = new File (filePath);
selenium.attachFile(fieldLocator, file.toURL().toString());

From what I know about the method attachFile it only works on Firefox.

Bobby
that is what i am doing. except the point that in java6 toURL() method is deprecated and i use toURI().toURL() instead - this leads to the above result.
endarkened