Enter a long multi-line text

How can i add multi-line texts in a multi line text field present in my website?

I tried using the set text (that empties the field if something is present there) but if i try to paste the text, only the first line is shown.

ok, so in the Input i put Variable and for value testObject? because i does not want to work

edit. THe browser opens until that step but nothing happens http://i.imgur.com/NxvSo8E.png

Hi,

Was struggling with the same today to add next lines in a textarea. Ended up creating a custom keyword which changes ‘\n’ from the input string to shift+enter keys too simulate the next line, hope this helps.

The custom keyword:

/**
* Set the text of a textarea, next line with '\n'.
* @param testObject Katalon test object.
* @param text Text to add too the textarea.
*/
@Keyword
def SetTextArea(TestObject testObject, String text) {
if(text.contains("\\n")){
text = text.replace("\\n", Keys.chord(Keys.SHIFT, Keys.ENTER))
}
else{
text = text.replace("\n", Keys.chord(Keys.SHIFT, Keys.ENTER))
}

WebUI.sendKeys(testObject, text)
}

Details about custom keywords: https://www.katalon.com/resources-center/tutorials/advanced/create-custom-keyword/

Let’s do it with the classic: http://www.lipsum.com/feed/html - (i think this comment section changes it a bit)

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin congue tempus tempor. Donec pretium viverra eleifend.

Aliquam et condimentum sem. Sed molestie nisl lectus, eget ultrices lorem tincidunt in. Morbi sed hendrerit dolor. Aliquam erat volutpat.

Integer maximus ex tempus auctor elementum. Vivamus vel lacus eu ante maximus consequat. Vestibulum lacus eros, gravida in massa ut, malesuada ultricies quam.

Suspendisse pharetra eros nec auctor posuere. Nunc sit amet dignissim eros. Suspendisse imperdiet tristique massa, id lacinia orci viverra id.

Etiam aliquam eros orci, eu malesuada ipsum commodo quis.

Hello. So how do i add this? keyword? could you please attach a pritnscreen?

Ok, all i had was a 1 day training about writing code. What i managed was to make a Keywords package and defined yourText as you said but honestly have no idea how to add that after the setText - text field object - …? value type ?

Sorry for my noob-ness

no luck, tried to copy texts with /n alsi with the Enter icon (from the Preview in dev mode) but it just writes the characters in the text like “↵This” and /“n This” in a single line.

And how do you want to fill these text fields? Do you have some test data which you take and you want to use them in text fields?

Hello, try to add a line separators into a single setText method.
WebUI.setText(testObject, "first line\nsecondline\nthird line")

Ok here is it:
def yourText = ‘’’
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin congue tempus tempor. Donec pretium viverra eleifend.
Aliquam et condimentum sem. Sed molestie nisl lectus, eget ultrices lorem tincidunt in. Morbi sed hendrerit dolor. Aliquam erat volutpat.
Integer maximus ex tempus auctor elementum. Vivamus vel lacus eu ante maximus consequat. Vestibulum lacus eros, gravida in massa ut, malesuada ultricies quam.
Suspendisse pharetra eros nec auctor posuere. Nunc sit amet dignissim eros. Suspendisse imperdiet tristique massa, id lacinia orci viverra id.
Etiam aliquam eros orci, eu malesuada ipsum commodo quis.
‘’’
WebUI.setText(findTestObject(‘Page_CuraAppointment/txt_Comment’), yourText)
Here is the screenshot: http://prntscr.com/fgv3t0

Do you have a sample text so that I can try and give you the screenshot?

Thanks

Hi there,

Based on duyluong answer, please your multiple lines of text into the variable using triple single quoted, then use it, e.g
def yourText = ''' line one line two line three .... line n '''
WebUI.setText(findTestObject(’’), yourText)

Thanks

@ Marek Melocik: We will have to enter predefined texts, always different, but for testing purposes i will use a longer general text.

@duyluong Sorry i don’t understand what are you saying.

When i try to add a Value to the Set text, and paste the text that has new lines (enter) then only the first line get’s pasted in that field. As i am typing this i realized that the text is with \n in the dev (f12) response! i will try that, thanks.

Please try this

Eg:

def yourText = '''\

Your text here

'''

Thanks.

The thing is, that this website will have text fields that will have up to 600.000 characters (that’s the max i’ve seen so far) but mostly between 100’s and 1000’s, many of them having multiple lines. It would be nonsense for me to put a separator between every new line ( i want to use real data, not copy pasting 1000 words with separators between them)

@Francisc Lukacs said:
The thing is, that this website will have text fields that will have up to 600.000 characters (that’s the max i’ve seen so far) but mostly between 100’s and 1000’s, many of them having multiple lines. It would be nonsense for me to put a separator between every new line ( i want to use real data, not copy pasting 1000 words with separators between them)

Come on dude this is free open source and not a paid one where you or your company can demand features and functions…

Hello,

1. Put the multi-line text into an Excel file.
2. Import the Excel file into Data Files.
3. On your SetText step, the Value Type column should be “Test Data Value”. Modify the “Value” column to reflect the correct row/column from the Excel.

See: https://docs.katalon.com/display/KD/Manage+Test+Data

6.1.0

You can use groovy’s multi-line string along with sendKeys to get this to work:

inputText = """first line
second line"""

WebUI.sendKeys(findTestObject('your object here'), inputText)


Can someone help me…please how to edit this configuration…
cause after i make setText and it wont be add into the line…
plus it couldn’t verify which part that i want to delete and add.