rahul
rahul

Reputation: 366

Selenium IDE, path of file to be uploaded is to be made relative.

I am using selenium IDE to make automated test cases for my webapp.

scenario - to test file upload.

Directory structure :-

myapp/ 
      testsuite/
                Resources (contains csv upload file)
                folder for testsuit(contains testsuit and relevent testcase files)                         

Issue - currently i am making test suits on my local machine, so the path of file to be uploaded is local to my system. now if any other team member runs test suit on his system/server then the path of upload file need to be changed. but this is a bad practice to change the path for each system. so, i am trying to make path of the upload file relative to location of my tests suit file.

<tr>
<td>type</td>
<td>id=QuestionUpload_file</td>
<td>/home/sbl4/public_html/atumbarium/testsuite/resources/question_upload.csv</td>
</tr>

I tried the approach specified in following post:- Can you specify a 'relative' path for the data file using Sel-Blocks Selenium add-on?

Upvotes: 3

Views: 3081

Answers (1)

Lee Kowalkowski
Lee Kowalkowski

Reputation: 11751

Plugin-free solution:

<tr>
    <td>storeEval</td>
    <td>Preferences.getString(TestSuite.TEST_SUITE_DIRECTORY_PREF);</td>
    <td>testSuiteFolder</td>
</tr>
<tr>
    <td>type</td>
    <td>id=QuestionUpload_file</td>
    <td>${testSuiteFolder}/resources/question_upload.csv</td>
</tr>

No config necessary.

Upvotes: 3

Related Questions