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.

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

remove the assignments:

<tr>
    <td>storeEval</td>
    <td>location.pathname.split( '-|' )[1]</td>
    <td>new</td>
</tr>
  • Sorry for the long wait. Nope that didnt work either still the same result echo: null – Theo Apr 17 '12 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, privacy policy and cookie policy

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