How to read and edit.txt file

Hi, I have a requirement as below. I want to read .txt file and compare the text from .txt file with text from the website. will you please help me with this.

Hi Manujushbarkade,

You can do that with this kind of approach. . .

//import file utils

//create instance
File file = new File("C:\\textFilePath.txt")
String text = FileUtils.readFileToString(file)
println text

WebUI.verifyMatch("Actual_Text", text, true)
Assert.assertEquals(text, "Actual_Text")

param definitions
WebUI.verifyMatch(String actualText, String expectedText, boolean isRegex)

Assert.assertEquals(Object expected, Object actual)

Hope that helps. . .:slight_smile:

1 Like

Below tutorial on read from file