Solved
Forum Discussion
- Vivek72ContributorHi Dev
Try using Textarea_Object.Keys("^a" & "[Del]"); without loop.
Regards
Kumar - UnveN
Staff
Hi!
You can use the 'value' property of the text area:
http://www.w3schools.com/jsref/prop_textarea_value.asp - UnveN
Staff
Hi Dev,
glad it was helpful. The only downside of this approach is that it does not emulate an actual user interaction. If you simply need to automate clearing of the field - go for it. But if you need to test that the field handles user input correctly then you better go for one of the Keys approaches mentioned above. This is because the field might have specific event handler functions attached ('onkeydown' for example) and that functions will not be called if you simply change the "value" property. - googleid_118035ContributorHi All,
I just try with following code, but its only delete last charaters only from the text area.
Textarea_Object.Click();
var var1 = Textarea_Object.contentText;
var var2 = var1.length;
for (i = 0; i < var2; i++){
Textarea_Object.Keys("[BS]");
}
..........................
Thanks
Dev - Colin_McCraeCommunity HeroDepends what the text input is.
Rather than sending a backspace, try sending an "escape" keypress. With many text inputs, that will clear the field.
I suspect your loop sending backspaces is running too fast. Which is why you are only seeing one character being deleted. With loops like that, you often need to be careful that your keypresses, and what happens on screen, are properly synchronised.
If you force a delay in the loop so that after each backspace, it waits until the text content shortens by 1, it would probably work. - googleid_118035Contributor
Hi Stanislav,
Thanks for the information.
I just try with value property and its work, here is my code.
Textarea_Object.Click();
Textarea_Object.value = "";
..........................
Thanks
Dev