0

I've this global function in my site

function formatDate(_date) {
    return _date.getFullYear() + '/' + (_date.getMonth() + 1) + '/' + _date.getDate();
}

When I try to use it in the IDE with the following command

<tr>
    <td>type</td>
    <td>id=comments</td>
    <td>javascript{"e2e-" + formatDate(new Date())}</td>
</tr>

and I run the test then the IDE stay in that command forever but do not execute it.

What I'm doing wrong?

vcRobe
  • 1,671
  • 3
  • 17
  • 35

1 Answers1

0

I have a similar function in one of my scripts and found that they way to do it is to break it down into 2 parts. Execute the function and store it as a variable, and then use the variable for your command. e.g.

My function is named:

function getddmmyyyy() 

then in selenium I have a command to execute the javascript and store it

<tr>
    <td>storeEval</td>
    <td>getddmmyyyy</td>
    <td>date</td>
</tr>

and then for the command it is:

<tr>
    <td>click</td>
    <td>css=[value="${date}"]</td>
    <td></td>
</tr>
Jsmith2800
  • 1,113
  • 1
  • 9
  • 18
  • If I try using your example it works but in my case I need to pass the DATE as parameter to the function so when I run the test I get this error **[error] Threw an exception: Permission denied to access property "getFullYear"**. How can I fix this? – vcRobe May 25 '16 at 14:57