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
import org.apache.commons.io.FileUtils

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

WebUI.verifyMatch("Actual_Text", text, true)
//or
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

Hi,
Below tutorial on read from file