Selenium IDE how to remove double quotes from a variable string

1,720 views
Skip to first unread message

whopiecat

unread,
Aug 22, 2012, 5:37:44 PM8/22/12
to seleniu...@googlegroups.com
Hello:

I would like to do this in the Selenium IDE.
I would like to remove the double quotes from a string variable.

I have established the variable testKeyword.
<tr>
<td>store</td>
<td>javascript{storedVars.metaTags[storedVars.index]}</td>
<td>testKeyword
</td>

example: testKeyword = "child"
-------------------------------------------------------------------------------------------------------------------------
I would like to remove the double quotes from the string in the testKeyword variable.
-------------------------------------------------------------------------------------------------------------------------
I have tried several replace scripts:

<tr>
<td>store</td>
<td>javascript{storedVars.testKeyword.replace('&quot;','')}</td>
<td>testKeywordwoQuotes</td>
</tr>

<tr>
<td>runScript</td>
<td>javascript{storedVars.testKeyword.replace('&quot;','')}</td>
<td>testKeywordwoQuotes</td>
</tr>
<tr>
<td>storeEval</td>
<td>javascript{storedVars.testKeyword.replace('&quot;','')}</td>
<td>testKeywordwoQuotes</td>
</tr>

<tr>
<td>storeExpression</td>
<td>javascript{storedVars.testKeyword.replace('&quot;','')}</td>
<td>testKeywordwoQuotes</td>
</tr>

None of these code examples are removing the double quotes from the variable.

Any help would be appreciated with removing the double quotes from a variable.
Thanks



kiisu

unread,
Aug 22, 2012, 6:28:45 PM8/22/12
to seleniu...@googlegroups.com
<tr>
<td>storeEval</td>
<td>storedVars['testKeyword'].replace(/"/g,"";);</td>
<td>newKeyword</td>
</tr>

Peter Gale

unread,
Aug 23, 2012, 3:24:11 AM8/23/12
to Selenium Users
Kisu

Having quotes around a string seems quote unusual, and given that your seemingly valid attempts to remove the quotes from a string have failed, I think we need to ask: in what context are you seeing a string with quotes in it? how has it arisen? can you show us some screenshots where this situation is demonstrated?

Peter


Date: Wed, 22 Aug 2012 15:28:45 -0700
From: ki...@renewfund.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: Selenium IDE how to remove double quotes from a variable string
--
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/-/X5R4qDbaXdIJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

whopiecat

unread,
Aug 23, 2012, 4:50:54 PM8/23/12
to seleniu...@googlegroups.com
This group is great.
Thanks for all the help.

Kisu: I tried your example code and received [error] Threw an exception: missing ) after argument list.
My code is this:

<tr>
<td>storeEval</td>
<td>storedVars['testKeyword'].replace(/&quot;/g,&quot;&quot;;);</td>
<td>newKeyword</td>
</tr>



On Thursday, August 23, 2012 2:24:11 AM UTC-5, PeterJef...@Hotmail.co.uk wrote:
Kisu

Having quotes around a string seems quote unusual, and given that your seemingly valid attempts to remove the quotes from a string have failed, I think we need to ask: in what context are you seeing a string with quotes in it? how has it arisen? can you show us some screenshots where this situation is demonstrated?

Peter


Date: Wed, 22 Aug 2012 15:28:45 -0700
From: ki...@renewfund.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: Selenium IDE how to remove double quotes from a variable string

<tr>
<td>storeEval</td>
<td>storedVars['testKeyword'].replace(/"/g,"";);</td>
<td>newKeyword</td>
</tr>

Thanks
----------------------------------------------------------------------------------------------------- 

Peter Gale

unread,
Aug 23, 2012, 5:07:28 PM8/23/12
to Selenium Users
Kisu

Perhaps you'd answer my question now, then?

It might help.

Peter


Date: Thu, 23 Aug 2012 13:50:54 -0700
From: beaty...@gmail.com
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] Re: Selenium IDE how to remove double quotes from a variable string
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/XgwX_0FC3w8J.

kiisu

unread,
Aug 24, 2012, 11:56:59 AM8/24/12
to seleniu...@googlegroups.com
Peter,

Not me asking the question... it is me answering the question, easy enough to mix up.  I made a typo in my previous example.  See below.


whopiecat,

Sorry about that, there was an extra ; in the second td of the example I gave you.  Just remove that and it works.


<tr>
<td>storeEval</td>
<td>storedVars['testKeyword'].replace(/"/g,"");</td>
<td>newKeyword</td>
</tr>

It uses javascript syntax.  The semicolon represents the end of the statement, thus it was prematurely ending the line before the argument list was closed in my first example. This is why it generated the error.

replace(/"/g,"") takes all the "'s it encounters in your variable storedVars['testKeyword'] and replaces them with what is between the quotes in the second argument, which in this case is nothing.  Without the g in the /"/g it would only replace the first one.  replace, match and split can help you out a lot when you need to clean up strings.


-kiisu.

Beaty.paul

unread,
Aug 24, 2012, 12:51:53 PM8/24/12
to seleniu...@googlegroups.com
Thanks for the update and code explanation.



Sent from Samsung RUGBY® Smart.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/TY9kctW3s0QJ.

kiisu

unread,
Aug 24, 2012, 1:23:07 PM8/24/12
to seleniu...@googlegroups.com
You're welcome I hope you've found it helpful!

-kiisu.

Peter Gale

unread,
Aug 24, 2012, 2:03:40 PM8/24/12
to Selenium Users
Kiisu,

Sorry, yes I was directinig the question at whoopiecat.

If your solution doesn't work I think we need to see the context in which Whoopiecat is seeing the problem.

Peter


Date: Fri, 24 Aug 2012 08:56:59 -0700
From: ki...@renewfund.com
To: seleniu...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/TY9kctW3s0QJ.
Reply all
Reply to author
Forward
0 new messages