How to verify fields position in text file using Selenium Webdriver and Autoit

How to verify fields position in text file using Selenium Webdriver and Autoit

this is my text file which I used to open in notepad++ and manually verify all the columns position are correctly populated or not. Now I want to automate this.
So please help me
Thanks

Add Comment
2 Answer(s)

You dont need a Selenium and AutoIt to do this. Once you have a text file you can read it line by line to verify the content in a fixed order. Also if you have the expected results in exactly the way you want your actual file to appear, then you can simple do a bit by bit comparison using Java constructs.

Try a file reader class in java. If you are not able to find the solution after doing this do let us know.

Virender Singh Professor Answered on April 10, 2015.

Thanks Virender Singh.
I want to verify columns positions of my fields as defined in below image, starting position of the Date value .
Please suggest solution how  can i automate this.

RE: How to verify fields position in text file using Selenium Webdriver and Autoit
on April 10, 2015.

can u share a file with 4-5 records I will try to provide exact java code.

on April 13, 2015.

amitjain, Can u please tell me from where i can attach my file, as no option has given here.Thanks  

on April 13, 2015.

I dont know where to do attachments

u can send here amitjain.coer191@gmail.com

on April 15, 2015.
Add Comment

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Iterator;

import java.util.List;
public class FileRead {

//String[] Enum = {" "," "};

public void File(){

try {

File myFile = new File("C:\\Users\\amit.ja\\Desktop\\ciFile.txt");

FileReader fileReader = new FileReader(myFile);

BufferedReader br = new BufferedReader(fileReader);

String iRecord = null;

String[] iField = new String[10];

String sTemp=null;

ArrayList<String> iFieldSet= new ArrayList<String> ();

int iFiller=0;

while ( (iRecord=br.readLine())!= null){

//System.out.println(line) ;

iRecord.length();

iField= iRecord.split(" ");
for (int i=0;i<iField.length;i++) {

if (!iField[i].isEmpty()) {

if (iFiller>0) System.out.println("Filler length " + " = " + iFiller);iFiller=0;

System.out.println(iField[i] + " = " + iField[i].length());

//iFieldSet.add(iField[i]);
}

else {

iFiller++;

}

// if (!sTemp.isEmpty()) System.out.println(sTemp + " = " + sTemp.length());

}

Iterator it = iFieldSet.iterator();

while (it.hasNext()){
//TO DO Code.

}
}
br.close();

}
catch(Exception ex) {

ex.printStackTrace();

}

}
public void urlCheck() throws IOException, InterruptedException{

URL url = new URL("http://127.0.0.1:4725/wd/hub/status");

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.getURL();

if (conn.getResponseCode() != 200) {

throw new RuntimeException("Failed : HTTP error code : "

+ conn.getURL());

}

else System.out.println("conn.getResponseCode()" + conn.getResponseCode());

}
public static void main(String[] args) throws IOException, InterruptedException {

FileRead fr=new FileRead();

//fr.urlCheck();

fr.File();
}
}

amitjain Supporter Answered on April 15, 2015.
RE: How to verify fields position in text file using Selenium Webdriver and Autoit
on April 15, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.