You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Peri Stracchino <pe...@york.ac.uk> on 2012/04/24 18:02:11 UTC
user parameters in external filepaths
Hello
I hope I'v got the correct address here for the JMeter users discussion
list - apologies if not.
I'm using JMeter 2.5.1
I want to run a test which requires a different external file to be sent
with each
request. I had hoped to do this by passing a variable into the File Path
(the one
under 'send files with the request'). this variable is read in from a csv
file
and would allow me to construct the unique part of the file name.
the variable is specified like this
ID ${_StringFromFile(collnumsonly.txt)}
But this doesnt seem to work, because when I look at the error
message the variable hasnt been expanded - see below:
<responseData class="java.lang.String">java.io.FileNotFoundException:
C:\Jmeter2.5\jakarta-jmeter-2.5.1\bin\${ID}.txt (The system cannot find the
file
specified)
Is there any means by which I can do this in JMeter? Have i got my syntax
wrong or
am I simply trying to do something which wont work in jmeter? I'v googled
like a
very googly thing but cant seem to find an answer to this
Cheers!
Re: user parameters in external filepaths
Posted by Peri Stracchino <pe...@york.ac.uk>.
cheers Deepak, the ID variable itself was fine, the problem was the last
file separation character in the filepath - ie the '\' - was being
interporeted as an escape character which prevented the variable from being
recognised and expanded. Once I escaped the '\' everything worked
correctly. Took quite a while for the penny to drop though - its a bit of a
Gotcha.
Peri
On 24 April 2012 17:59, Deepak Shetty <sh...@gmail.com> wrote:
> Hi
> i think the ${ID} is inside the file collnumsonly.txt (which wont work.).
> Is that correct?
>
> regards
> deepak
>
>
>
>
> On Tue, Apr 24, 2012 at 9:51 AM, sebb <se...@gmail.com> wrote:
>
> > On 24 April 2012 17:02, Peri Stracchino <pe...@york.ac.uk>
> > wrote:
> > > Hello
> > >
> > > I hope I'v got the correct address here for the JMeter users discussion
> > > list - apologies if not.
> >
> > Yes, it is the correct list.
> >
> > > I'm using JMeter 2.5.1
> >
> > There is a more recent version (2.6) but that's unlikely to be the issue
> > here.
> >
> > > I want to run a test which requires a different external file to be
> sent
> > > with each
> > > request. I had hoped to do this by passing a variable into the File
> Path
> > > (the one
> > > under 'send files with the request'). this variable is read in from a
> > csv
> > > file
> > > and would allow me to construct the unique part of the file name.
> > >
> > > the variable is specified like this
> > > ID ${_StringFromFile(collnumsonly.txt)}
> >
> > Where are you defining this?
> >
> > > But this doesnt seem to work, because when I look at the error
> > > message the variable hasnt been expanded - see below:
> > > <responseData class="java.lang.String">java.io.FileNotFoundException:
> > > C:\Jmeter2.5\jakarta-jmeter-2.5.1\bin\${ID}.txt (The system cannot find
> > the
> > > file
> > > specified)
> >
> > This means that the variable cannot be resolved.
> >
> > > Is there any means by which I can do this in JMeter? Have i got my
> syntax
> > > wrong or
> > > am I simply trying to do something which wont work in jmeter? I'v
> googled
> > > like a
> > > very googly thing but cant seem to find an answer to this
> >
> > Syntax looks OK.
> >
> > There are two aspects to this:
> > 1) is the variable being set up correctly and in time?
> > 2) is the sampler set up correctly to use the variable?
> >
> > I would start by disabling reading from the external file.
> > Define the ID variable as a fixed value on the Test Plan, and make
> > sure the sampler works with the fixed value.
> > Change the value and check it still works.
> >
> > Then try to read the variable from the file; use the Debug Sampler to
> > show what variables are being set up.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > For additional commands, e-mail: user-help@jmeter.apache.org
> >
> >
>
Re: user parameters in external filepaths
Posted by Deepak Shetty <sh...@gmail.com>.
Hi
i think the ${ID} is inside the file collnumsonly.txt (which wont work.).
Is that correct?
regards
deepak
On Tue, Apr 24, 2012 at 9:51 AM, sebb <se...@gmail.com> wrote:
> On 24 April 2012 17:02, Peri Stracchino <pe...@york.ac.uk>
> wrote:
> > Hello
> >
> > I hope I'v got the correct address here for the JMeter users discussion
> > list - apologies if not.
>
> Yes, it is the correct list.
>
> > I'm using JMeter 2.5.1
>
> There is a more recent version (2.6) but that's unlikely to be the issue
> here.
>
> > I want to run a test which requires a different external file to be sent
> > with each
> > request. I had hoped to do this by passing a variable into the File Path
> > (the one
> > under 'send files with the request'). this variable is read in from a
> csv
> > file
> > and would allow me to construct the unique part of the file name.
> >
> > the variable is specified like this
> > ID ${_StringFromFile(collnumsonly.txt)}
>
> Where are you defining this?
>
> > But this doesnt seem to work, because when I look at the error
> > message the variable hasnt been expanded - see below:
> > <responseData class="java.lang.String">java.io.FileNotFoundException:
> > C:\Jmeter2.5\jakarta-jmeter-2.5.1\bin\${ID}.txt (The system cannot find
> the
> > file
> > specified)
>
> This means that the variable cannot be resolved.
>
> > Is there any means by which I can do this in JMeter? Have i got my syntax
> > wrong or
> > am I simply trying to do something which wont work in jmeter? I'v googled
> > like a
> > very googly thing but cant seem to find an answer to this
>
> Syntax looks OK.
>
> There are two aspects to this:
> 1) is the variable being set up correctly and in time?
> 2) is the sampler set up correctly to use the variable?
>
> I would start by disabling reading from the external file.
> Define the ID variable as a fixed value on the Test Plan, and make
> sure the sampler works with the fixed value.
> Change the value and check it still works.
>
> Then try to read the variable from the file; use the Debug Sampler to
> show what variables are being set up.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>
Re: user parameters in external filepaths
Posted by sebb <se...@gmail.com>.
On 24 April 2012 17:58, Peri Stracchino <pe...@york.ac.uk> wrote:
> I'v just figured the problem out!!!!!!!!!!!
> I specified the path thus
> C:\Jmeter2.5\jakarta-jmeter-2.5.1\bin\${ID}.txt
> The penny suddenly dropped. The path separator was being interpreted as an
> escape character, and the dollar sign was then being treated literally
> rather than as indicating the start of a variable to expand
> So I tried escaping the last path separator like so:
> C:\Jmeter2.5\jakarta-jmeter-2.5.1\bin\\${ID}.txt
>
> and all was well :-), the variable now expands and my files are uploaded
Rats! I should have noticed that; another user had a similar issue a
few months back.
It's unfortunate that the escape character is the same as the Windows
path separator.
BTW, you can use / instead of \ on Windows; Java converts as necessary.
Also, JMeter can use relative path names.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
Re: user parameters in external filepaths
Posted by Peri Stracchino <pe...@york.ac.uk>.
I'v just figured the problem out!!!!!!!!!!!
I specified the path thus
C:\Jmeter2.5\jakarta-jmeter-2.5.1\bin\${ID}.txt
The penny suddenly dropped. The path separator was being interpreted as an
escape character, and the dollar sign was then being treated literally
rather than as indicating the start of a variable to expand
So I tried escaping the last path separator like so:
C:\Jmeter2.5\jakarta-jmeter-2.5.1\bin\\${ID}.txt
and all was well :-), the variable now expands and my files are uploaded
thanks for getting back on this
Peri
On 24 April 2012 17:51, sebb <se...@gmail.com> wrote:
> On 24 April 2012 17:02, Peri Stracchino <pe...@york.ac.uk>
> wrote:
> > Hello
> >
> > I hope I'v got the correct address here for the JMeter users discussion
> > list - apologies if not.
>
> Yes, it is the correct list.
>
> > I'm using JMeter 2.5.1
>
> There is a more recent version (2.6) but that's unlikely to be the issue
> here.
>
> > I want to run a test which requires a different external file to be sent
> > with each
> > request. I had hoped to do this by passing a variable into the File Path
> > (the one
> > under 'send files with the request'). this variable is read in from a
> csv
> > file
> > and would allow me to construct the unique part of the file name.
> >
> > the variable is specified like this
> > ID ${_StringFromFile(collnumsonly.txt)}
>
> Where are you defining this?
>
> > But this doesnt seem to work, because when I look at the error
> > message the variable hasnt been expanded - see below:
> > <responseData class="java.lang.String">java.io.FileNotFoundException:
> > C:\Jmeter2.5\jakarta-jmeter-2.5.1\bin\${ID}.txt (The system cannot find
> the
> > file
> > specified)
>
> This means that the variable cannot be resolved.
>
> > Is there any means by which I can do this in JMeter? Have i got my syntax
> > wrong or
> > am I simply trying to do something which wont work in jmeter? I'v googled
> > like a
> > very googly thing but cant seem to find an answer to this
>
> Syntax looks OK.
>
> There are two aspects to this:
> 1) is the variable being set up correctly and in time?
> 2) is the sampler set up correctly to use the variable?
>
> I would start by disabling reading from the external file.
> Define the ID variable as a fixed value on the Test Plan, and make
> sure the sampler works with the fixed value.
> Change the value and check it still works.
>
> Then try to read the variable from the file; use the Debug Sampler to
> show what variables are being set up.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>
Re: user parameters in external filepaths
Posted by sebb <se...@gmail.com>.
On 24 April 2012 17:02, Peri Stracchino <pe...@york.ac.uk> wrote:
> Hello
>
> I hope I'v got the correct address here for the JMeter users discussion
> list - apologies if not.
Yes, it is the correct list.
> I'm using JMeter 2.5.1
There is a more recent version (2.6) but that's unlikely to be the issue here.
> I want to run a test which requires a different external file to be sent
> with each
> request. I had hoped to do this by passing a variable into the File Path
> (the one
> under 'send files with the request'). this variable is read in from a csv
> file
> and would allow me to construct the unique part of the file name.
>
> the variable is specified like this
> ID ${_StringFromFile(collnumsonly.txt)}
Where are you defining this?
> But this doesnt seem to work, because when I look at the error
> message the variable hasnt been expanded - see below:
> <responseData class="java.lang.String">java.io.FileNotFoundException:
> C:\Jmeter2.5\jakarta-jmeter-2.5.1\bin\${ID}.txt (The system cannot find the
> file
> specified)
This means that the variable cannot be resolved.
> Is there any means by which I can do this in JMeter? Have i got my syntax
> wrong or
> am I simply trying to do something which wont work in jmeter? I'v googled
> like a
> very googly thing but cant seem to find an answer to this
Syntax looks OK.
There are two aspects to this:
1) is the variable being set up correctly and in time?
2) is the sampler set up correctly to use the variable?
I would start by disabling reading from the external file.
Define the ID variable as a fixed value on the Test Plan, and make
sure the sampler works with the fixed value.
Change the value and check it still works.
Then try to read the variable from the file; use the Debug Sampler to
show what variables are being set up.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org