How to highlight or select specific text?

Here is my scenario…i have to create parents and indeed i need to create childrens for selected parent.
suppose if i have created 4 parents like
parent 1
parent 2
parent 3
parent 4

now i need to create childrens for parent 3…how to select that parent 3 item which is begining displayed on the left side panel and focus of the cursor is not there on any item.I need to get the focus of the cursor or select the specific parent or desired parent then i need to click on add children button to add childrens.

Hope u got my Scenario. Please help me in this…this is very urgent for me

Are the parent nodes actually represented by the word “parent”? Or is there an icon that you are looking for? There are a couple of approaches that would work. If you have the word “parent” repeatedly or an icon representing a parent node, then you can use an image like this:

// start by finding all of the parent nodes
put everyImageLocation("parentNodeImage") into parents
// now click the particular parent that you want to work with
click item 3 of parents

But note that if you want to work with each of the parent nodes, you’ll probably need to use the “put everyImageLocation()” code before selecting each parent because adding child nodes will probably change the positions of the parent nodes on the screen. EveryImageLocation() looks for the specified image, but returns a list of coordinates where that image was found.

The other approach that might be necessary is to use text images. If the parent nodes are represented by dynamically generated strings, then you can search for those strings using text images. So lets say that you first create parent nodes called “Red”, “Yellow”, and “Orange” that are represented by those strings. To click on the “Yellow” parent node, you would use code like this:

Click (Text:"Yellow", TextSize:"12", TextFont:"Times")

The text properties used here are just examples; you would need to know or determine the actual properties of the font used to display the nodes.

Hope that helps.

Neither there is no fixed parent text not any parent icon…the parent name is dynamically given. im asking for the user prompt to give the desired name and when ones the user have given his desired name i will create the parent with that name and now i need to create childrens for that parent…

whether the second approach will work by making use of text images ??

If you’re doing this for testing, wouldn’t it be better to have a set of known values? That way you can take advantage of the automation and have the test run any time, whether someone is around to enter values or not. You could also create a data-driven test using values from a file.

If you’re going to do it all dynamically then you’re going to have to use text images (that’s what the feature was created for). You’ll need to store the string that the user enters (or that you read from the file if you go the data-driven route) and then use that value for the Text property of the text image.

Hi EggPlantMatt,

Hope you didnot got my scenario… here it is ,im explaining clearly.

My intension is to create a parent and add childrens for that parent. So while creation of parent the parent name is dynamic, the user can give what ever the name he likes. so when the parent is created, it will be displayed on the extreme left side panel of the UI. The focus of the cursor will not be there on the created parent item.Now i need to select that parent and add childrens for that parent.

I have Created the Script for Creation of parent, now my script need to select the created parent and then add childrens.

How can i select that item thru eggplant or sense talk.

As per your reply i cant capture the image of the created parent as the parent name is dynamic and i have tried with Text image capturing…even it is working.

Please give me solution as it is very urgent for me…

Your best bet is the text image approach. If you don’t understand how the text images work, you should read the information on the topic in the Using Eggplant reference. You will need to know the font and text size that are used to display the parent nodes in order for your text images to match. If you continue to have difficulty with it, send a screenshot and some samples of your text image code to the TestPlant support address and we may be able to help you.

I have been trying to get the text image to work, but I think it doesn’t like text with spaces. I can get the generator to to pick up some of the text I am searching, including a comma and a space after. But, when I enter another letter after the comma and space, the generator doesn’t see the text. I have included a screen shot collage to demonstrate.

Mark

Yes, spaces can be a problem since there is often not a fixed size for a space and the TIG gets whatever the OS returns, which may not be the same thing that is generated by the application. Is this example a good representation of what you are testing? If so, why worry about the whole string? Just have it look for the unique part and drop the “MDMSEP, " and " NMN” bits – if it will match the contiguous string in the middle, then eggPlant can click that choice. Would that satisfy your requirement?

Actually, yes. Hadn’t thought about it that way.

Thanks!

It doesn’t seem to like long text strings either. Trying to generate from TWENTYTWOTENFIVE gives an error, whereas searching for FIVE works. Not to mention that the text TWENTYTWOTENFIVE appears mulitple times on the SUT screen, whereas MDMSEP, TWENTYTWOTENFIVE NMN is unique. I included a screenshot here that has it twice in the same dialog for instance Dunno.

Ultimately, I wanted to do this dynamically, by trying to get this bit of code to work?

This is the bit that does the search for the patient, which will then will result in a list to select from:


ask "Please enter the patients first name"
put it into patFirstName
TypeText it

This is the code that, hopefully, I can dynamically generate a text image from somehow:


ask "Type in the first name you want to select in the SUT..." with patFirstName

click (Text:it)

[quote=“mappingman”]Actually, yes. Hadn’t thought about it that way.

Thanks!

What are your font settings? If the font is less than 10 pts in size, try reducing the font size setting by .25. So if you currently have a font size of 8 pts, for example, try changing it to 7.75 pts and see if that works any better.

I have seen issues with strings of capital letters in some cases, so the above may not work, but it’s easy to test.

Yeah, I really have no idea what font they are using in the system. Not even sure if I can get that information.

[quote=“EggplantMatt”]What are your font settings? If the font is less than 10 pts in size, try reducing the font size setting by .25. So if you currently have a font size of 8 pts, for example, try changing it to 7.75 pts and see if that works any better.

I have seen issues with strings of capital letters in some cases, so the above may not work, but it’s easy to test.[/quote]

Reducing by .25. seems to allow the generation of the click command - click (Text:“FIVE NMN”), but the actual click does not occur when the script is run.

If the click command was executed, check the results and see at what coordinates the click occurred. It could be that eggPlant thinks it found the text somewhere else on the screen. Have you seen issues with any other clicks in your scripting?