Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

selenium

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?

like image 754
rahul Avatar asked Nov 28 '25 14:11

rahul


1 Answers

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.

like image 109
Lee Kowalkowski Avatar answered Dec 01 '25 18:12

Lee Kowalkowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!