Delete text - web

Hi all

What is the command or how can I delete text that written in search filed, I need to insert step after the field is empty. I saw there is a clear text in mobile - but I need it in the web. tnx

I simulate doubleclicking the text and pressing back space:

String str = WebUI.getAttribute(findTestObject("search_box"), 'value')
int n=str.count(' ')+2
println n
n.times {
        WebUI.doubleClick(findTestObject("search_box"))
        WebUI.sendKeys(findTestObject("search_box"), Keys.chord(Keys.BACK_SPACE))
}
1 Like

Mate Mrse said:

I simulate doubleclicking the text and pressing back space:

String str = WebUI.getAttribute(findTestObject("search_box"), 'value')

int n=str.count(’ ')+2
println n
n.times {
WebUI.doubleClick(findTestObject(“search_box”))
WebUI.sendKeys(findTestObject(“search_box”), Keys.chord(Keys.BACK_SPACE))
}


  

  

Why the “count” doesn’t recognize ?

Kat.png

Don’t wory about that. It is supposed to indicate an deprecated groovy method. But it will work.

Also, be sure to import

import org.openqa.selenium.Keys
1 Like

It’s not delete all.
do I need to make some changes in code?

{
“secret”: “1298”,
“sessionType”: “SINGLE_SIGNON”,
“storeId”: 144271,
“userName”: “kassor.1@baleron.se”
}

Just fill in an empty string?

WebUI.setText(findTestObject("search_box"), "")