Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

2 Answers 2

remove the assignments:

<tr>
    <td>storeEval</td>
    <td>location.pathname.split( '-|' )[1]</td>
    <td>new</td>
</tr>
share|improve this answer
    
Sorry for the long wait. Nope that didnt work either still the same result echo: null –  Theo Apr 17 '12 at 13:28
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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