0

I am writing FuncUnit for my application. I am browsing the application in Google Chrome. I have a textbox which is initially hidden. I need to make it visible and then clear the text already present in that textbox. I have the following code which makes the box visible but fails to clear the text in it.

 S('#search').visible().clearText();

Can anyone tell what is wrong here?

SKR
  • 473
  • 1
  • 5
  • 11

4 Answers4

0

Try to clear the textbox by typing - Ctrl+A and Delete.

var input = S('input.my-input');

input.type('[ctrl]a[ctrl-up][delete]', function() {
    // Continue in test case after the text has been removed
});
koalix
  • 133
  • 2
  • 7
0

Your statement is not accurate. visible() does not turn things visible. It is a wait function which waits for the source element to become visible before proceeding to the next action.

koalix's key sequence works. With the type() command you might need to first click into the text input before clearing it.

Try:

S('#search').visible().click().type('[ctrl]a[ctrl-up][delete]');
Dave Alperovich
  • 32,320
  • 8
  • 79
  • 101
SimoAmi
  • 1,696
  • 14
  • 13
0

You could also try empty quotes <" ">

var input = S('input.my-input');

input.type('', function() {
    // remove existing text
});
500KD
  • 46
  • 5
-1

I don't know if you're still waiting for an answer. I think you're not using visible() in the correct way.

In FuncUnit (see docs here), among other things, you can distinguish between "actions" and "waits". visible() is a wait, and should be used to wait for an element to become visible, like this:

    S('#el').visible( function() {
        // do something when element with id="el" becomes visible
    });
j0k
  • 22,600
  • 28
  • 79
  • 90
Benito
  • 710
  • 5
  • 10