Re: Se: how to substr inside IDE

1,794 views
Skip to first unread message

sai kiran nukala

unread,
Sep 11, 2012, 3:21:16 AM9/11/12
to seleniu...@googlegroups.com
use   string substring() function in javascript 

On Tuesday, 11 September 2012 00:00:37 UTC+5:30, Viktor Mo wrote:
Hi, can anybody help how to do right syntax for subscript method inside IDE, no matter what I tried it failes for now:

CODE:

| StoreText | //*[@id="M_MainContent_Amount"]  | amt1
| echo    | ${amt1| |                  //** $14.34

Now I need to cut of that dollar sign $ to get  just <14.34>???
| StoreText | javascript{$amt1.substr(1)  | amt1a    //-- ERROR


Thanks all
Dai 

sumana madgula

unread,
Sep 12, 2012, 5:17:52 AM9/12/12
to seleniu...@googlegroups.com
Try with below code :
<tr>
    <td>store</td>
    <td>$14.34</td>
    <td>amt</td>
</tr>
<tr>
    <td>echo</td>
    <td>${amt}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>javascript{storedVars['amt'].substring(1,6)}</td>
    <td>A</td>
</tr>
<tr>
    <td>echo</td>
    <td>${A}</td>
    <td></td>
</tr>

from Sumana

On Tue, Sep 11, 2012 at 11:59 PM, Viktor Mo <dai...@yahoo.com> wrote:
Guys, can gimme a syntax for this in IDE, what I am missing, why it doesn't work inside IDE, do I need to install any Var plug in???


CODE:

| StoreText |"$1111.33"]  | amt1
| echo    | ${amt1| |                  //** $1111.33

How to cut this "$" off???
| StoreText | javascript{(String($amt1)).substr(1)}  | amt1a    //-- ERROR tried all combo with this String/amt1/substr/{}$...etc


Thanks all
Dai 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/gX86YArL9w4J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

kiisu

unread,
Sep 12, 2012, 12:21:17 PM9/12/12
to seleniu...@googlegroups.com
In the IDE the javascript wrapper is not required on storeEval, it is only necessary when you want to execute javascript on a command that is not an eval.

<tr>
<td>storeEval</td>
<td>storedVars['amt'].substring(1,6)</td>
<td>A</td>
</tr>

-kiisu.

sumana madgula

unread,
Sep 17, 2012, 4:18:35 AM9/17/12
to seleniu...@googlegroups.com
Hi

Go through the link you will understand the usage:

http://codemamba.com/storing-variables-in-selenium-ide/

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/rWsD29j4SrYJ.

kiisu

unread,
Sep 17, 2012, 3:25:27 PM9/17/12
to seleniu...@googlegroups.com
sumana, 

To clarify my previous post.  Your storeEval line has an unnecessary javascript wrapper.  

your example:

<tr>
    <td>store</td>
    <td>$14.34</td>
    <td>amt</td>
</tr>
<tr>
    <td>echo</td>
    <td>${amt}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>javascript{storedVars['amt'].substring(1,6)}</td>
    <td>A</td>
</tr>
<tr>
    <td>echo</td>
    <td>${A}</td>
    <td></td>
</tr>

does exactly the same thing as:

<tr>
    <td>store</td>
    <td>$14.34</td>
    <td>amt</td>
</tr>
<tr>
    <td>echo</td>
    <td>${amt}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>storedVars['amt'].substring(1,6)</td>

    <td>A</td>
</tr>
<tr>
    <td>echo</td>
    <td>${A}</td>
    <td></td>
</tr>

notice I have removed "javascript{}"

storeEval gets the result of evaluating the specified JavaScript snippet.
You can force the "store" command to execute javascript by including the javascript wrapper such as you have, but it is entirely superfluous when running it in a command that is specifically intended to execute javascript.

-kiisu.

sumana madgula

unread,
Sep 18, 2012, 2:07:27 AM9/18/12
to seleniu...@googlegroups.com
Thank you kiisu for clarifying.

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/XzHw7AA5essJ.
Reply all
Reply to author
Forward
0 new messages