How to get value of the textbox or textarea?

In my case there is textbox or textarea which is already prefilled and i need to retrieve it’s value and want to store in a variable

String title = WebUI.getText(findTestObject('Page_Dashboard/input_title')

 

In above code title is the textbox whose value is already prefilled. Unfortunately getText only works for text/label not for textbox.

So in this case you can use ‘Get Attribute’ keyword and pass in ‘value’ attribute to retrieve its value, e.g:

String title = WebUI.getAttribute(findTestObject('Page_Dashboard/input_title'), 'value')

1 Like

Hi, i have a problem. I have a this code:

WebUI.setText(findTestObject(‘Object Repository/Aconcagua Latam PRE/InformeCajeroFisico/Page_Alira/input_Fecha Inicial_transaction_startDate’), ‘01/01/2019 00:00:00’)

but besides the date it automatically puts the current date

I have tried everything before:

  • WebElement fechaInicial = driver.findElement(By.xpath(‘/html[1]/body[1]/div[2]/div[11]/div[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/input[1]’)).clear()
  • WebUI.clearText(findTestObject(‘Object Repository/Aconcagua Latam PRE/InformeCajeroFisico/Page_Alira/input_Fecha Inicial_transaction_startDate’))

And I can not put only the desired date. → ‘01/01/2019 00:00:00’
Can you help me?

I solved it by deleting the textbox of date type with the line before:

WebUI.sendKeys(findTestObject(‘Object Repository/Aconcagua Latam PRE/InformeCajeroFisico/Page_Alira/input_Fecha Inicial_transaction_startDate’), Keys.chord(Keys.DELETE))

you must import the example libraries:
https://docs.katalon.com/katalon-studio/docs/webui-send-keys.html#example