0

One of my webdriver testcases does a file upload to the website, in order to test that attachments can be added to message posts. This is implemented easily enough with a single line of code:

fileInputControl.sendKeys(fullFilePath);

The problem is how to define, as part of the test data parameters, a string which represents a known sample file available for upload. I developed the testcase on my windows 7 PC, and the sample Chrysanthemum.jpg file is pretty much guaranteed to exist in anybody's Pictures folder (assuming they're running Windows 7), so I've got this code defining the test data:

fullFilePath = System.getenv("PUBLIC") + "\\Pictures\\Sample Pictures\\Chrysanthemum.jpg";

My problem is that now I now need to start running this test on other OSes which I'm not as familiar with: Android, OSX, iOS, Windows 8, Windows 10. Does anybody know if there are similar 'sample' files which I can rely on in those platforms?

4
  • 1
    Why cant you just write your own file first then upload that file? – Matt Johnson Jul 6 '15 at 17:01
  • Beware network installs. These can have different paths from "regular"installs. – Bookeater Jul 6 '15 at 19:06
  • @MattJohnson I might try that, yes; but it would be a bit more code to implement, and slower to run - if I can rely on files which already exist that's just easier. – Vince Bowdren Jul 6 '15 at 20:04
  • iOS does not expose a file system to the web browser. Android does not either. – user246 Jul 6 '15 at 23:24
1

If you can create files in a known space with known filenames you eliminate this problem. By so doing you now have a set of test data. This data needs to be versioned in sync with the automation.

The downside is you now have to manage data as well as automation scripts to ensure your scripts work as expected. The upside is that you can create files with errors in them and include some negative testing in your scripts, as well as not having to rely on files that may or may not change outside of your control.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.