1

I am trying to use js split in one of my tests. I need to store a url and save the last part of the url in a log file. I have stored the url successfully but I can't get the slit to work. So far I have the following:

<tr>
    <td>store</td>
    <td>&quot;http://www.exampleUrl.com/xxxxxxxxxxxxxxxxxx/-|845290&quot;</td>
    <td>a</td>
</tr>
<tr>
    <td>echo</td>
    <td>${a}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>var pathArray = location.pathname.split( '-|' ); var a= pathArray[1];</td>
    <td>new</td>
</tr>
<tr>
    <td>echo</td>
    <td>${new}</td>
    <td></td>
</tr>

But when ever I run it I am getting an echo = null.

2
  • Can you echo location.pathname?
    – user246
    Commented Mar 6, 2012 at 17:52
  • Thanks for the reply Nope i still get the same response echo:null
    – Theo
    Commented Mar 7, 2012 at 15:09

2 Answers 2

2

remove the assignments:

<tr>
    <td>storeEval</td>
    <td>location.pathname.split( '-|' )[1]</td>
    <td>new</td>
</tr>
1
  • Sorry for the long wait. Nope that didnt work either still the same result echo: null
    – Theo
    Commented Apr 17, 2012 at 13:28
0

Try out below code

store | http://www.exampleUrl.com/xxxxxxxxxxxxxxxxxx/-|845290 | URL
store | 1 | delimiter
store | javascript{storedVars['URL'].split('/-|')[storedVars['delimiter']]} | result
echo  | ${result}

Result will be - 845290

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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