user3794115
user3794115

Reputation: 11

Selenium IDE Using stored variable in javascript command

I want to create a JavaScript date using text I stored from my site. This is what I tried:

<tr>
    <td>storeValue</td>
    <td>name=contract_additional_fields[agreement_created_date]</td>
    <td>seleniumContractDateValue</td>
</tr>
<tr>
    <td>echo</td>
    <td>javascript{Date.parse('${seleniumContractDateValue}')}</td>
    <td></td>
</tr>

I also tried using nothing or "" in the parse but neither one worked.

Can anyone help me figure out how I use a stored variable as a parameter of a JavaScript command?

Upvotes: 1

Views: 4240

Answers (1)

ism
ism

Reputation: 298

1.you access variables with "storedVars['seleniumContractDateValue']" in JavaScript.

2.Selenium won't store a JavaScript date object, so you will need to parse it into a string as well.

<tr>
    <td>storeValue</td>
    <td>name=contract_additional_fields[agreement_created_date]</td>
    <td>seleniumContractDateValue</td>
</tr>
<tr>
    <td>store</td>
    <td>javascript{Date.parse(storedVars['seleniumContractDateValue'])}</td>
    <td>seleniumContractDateValue</td>
</tr>
<tr>
    <td>echo</td>
    <td>${seleniumContractDateValue}</td>
    <td></td>
</tr>

Upvotes: 2

Related Questions