Click on the first element in table

I am trying to write script on clicking on the first element in table but not sure how to achieve this.
I looked at the readTable documentation http://docs.eggplantsoftware.com/ePF/SenseTalk/stk-ocr-text-reading-functions.htm#readtable-function
In the link above how can I click on first item in column Topic? in this case it is “Course Introduction”
On our UI it can be any text

When Eggplant reads text it not not capture additional info like the location of that text or table element information.

I would use points and rectangles to read each line of the table. Example based off the class schedule in the ReadTable document you linked.

//if you are just interested in clicking each row, and not reading it, you can just use the location and shift down a certain number of pixels

put 1 into rowNum
put 30 into rowHeight 

put Imagelocation(text:"topic") into TopicColumnLocation 
click TopicColumnLocation + (0, rowNum*RowHeight) //shifting the point to click down to whichever row I want to click

If you want to read each line of the table and do checks on them, I would use rectangles and readtext:

 //Get the Column header for the column you are interested in reading. Its easiest to make sure the image is of the entire column
put ImageRectangle("TopicColumnHeader") into TopicColumnSquare

put TopicColumnSquare.height into RowHeight //figure out how wide the rows are

repeat 7 times 
	add (0,RowHeight,0,RowHeight) to TopicColumnSquare // shift the square  down for each row
	log "Row " & repeatindex()
	log readtext(TopicColumnSquare)
	
	//if you want to validate other items on the same line you can also shift the box to the right or left
	if readtext (TopicColumnSquare+(-100,0,-420,0)) equals repeatindex() //shifting the box right to read the first column)
		click TopicColumnSquare.center
	end if
	
end repeat

If you do use points and rectangles, I would add the Cursor Location button in the SUT window (right click the toolbar -> Customize Toolbar -> Cursor Location (looks like a white box) -> drag it to your toolbar). Also to quickly capture the rectangle values to figure out your offsets you can go into capture mode, highlight the area in question type Control + C (as if you were copying text) and Control + V in Eggplant Functional to get the coordinates for the rectangle you highlighted.

1 Like