Clearing input textbox using FuncUnit

454 views Asked by At

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?

4

There are 4 answers

0
Benito On

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
    });
0
500KD On

You could also try empty quotes <" ">

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

input.type('', function() {
    // remove existing text
});
0
SimoAmi On

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]');
0
koalix On

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
});