0

I have copied some text from the website and then pasted it into the text file. And also I did the same thing to paste the second text using the "Append To File" keyword. I want to paste the first text in the first row and the second text in the next row. How could I do that?

This is what I have so far,

*** Test Cases ***

TC_01

Open Browser    ${BASE_URL}     gc
EXECUTE JAVASCRIPT    window.scrollTo(200,400)
sleep  5s

${Text} =  Get Text    xpath=//div[2]/md-card/header/h2
${Value} =  Get Text    css=.recommended-size
createFile     C:/MyProjects/Records/File.txt      ${Text}
Append To File      C:/MyProjects/Records/File.txt    ${Space}
Append To File      C:/MyProjects/Records/File.txt   ${Value}

log to console   success
sleep  2s

Screenshot 1 - Result

I got the result as the above screenshot, and what I want to do is, I want to paste the "1km" on the next line.

Please help to solve this issue. Any guidance and advice will be greatly appreciated!

2 Answers 2

0

You can try this

${Text} =  Catenate    SEPARATOR=    Text1    \n     Text2     \n 
${Value}     set variable  Text4
createFile          ${EXECDIR}/File.txt      ${Text}
Append To File      ${EXECDIR}/File.txt   ${Value}
0

You can add a newline character to separate the text between different lines.

You can use the following code to add a newline character before appending the second text to the file:

*** Test Cases ***

TC_01

Open Browser ${BASE_URL} gc
EXECUTE JAVASCRIPT window.scrollTo(200,400)
sleep 5s

${Text} = Get Text xpath=//div[2]/md-card/header/h2
${Value} = Get Text css=.recommended-size
createFile C:/MyProjects/Records/File.txt ${Text}
Append To File C:/MyProjects/Records/File.txt \n
Append To File C:/MyProjects/Records/File.txt ${Value}

log to console success
sleep 2s

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.