Could I find and select text in Textarea?

Ask general questions here.
zhuxy2000
Posts: 5
Joined: Fri Oct 26, 2012 3:57 pm

Could I find and select text in Textarea?

Post by zhuxy2000 » Fri Oct 26, 2012 4:16 pm

I want to find special string in textarea and then insert something

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Could I find and select text in Textarea?

Post by Ciege » Fri Oct 26, 2012 4:19 pm

You will need to phrase your question a little better than that...

What type of AUT?
What IDE are you using (VS/Ranorex Studio)?
Are you using user code or recording?
What have you already tried?

The more information you provide the better we will be able to assist you...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

zhuxy2000
Posts: 5
Joined: Fri Oct 26, 2012 3:57 pm

Re: Could I find and select text in Textarea?

Post by zhuxy2000 » Fri Oct 26, 2012 5:09 pm

I am testing web based application. We develop code in Visual Studio 2012 and import ranorex dll.
In textarea we long text like this:

jksadgjhsdfg() sdjksdfg [~11~] jsdgfjsd{}kfkdfgj()
...
...

We want to insert different stuff in () or {} or [~11~] . I try to move cursor to these special strings and right click mouse to insert parameters selected from popup menu

Thanks a lot

zhuxy2000
Posts: 5
Joined: Fri Oct 26, 2012 3:57 pm

Re: Could I find and select text in Textarea?

Post by zhuxy2000 » Fri Oct 26, 2012 5:13 pm

Could I treat textarea text as Ranorex.text and then move the cursor to the special string?

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Could I find and select text in Textarea?

Post by Ciege » Fri Oct 26, 2012 5:21 pm

I still fully don't understand your question... However...

If you have the textarea (as you call it) as an element and you can click on it (which sets the element as the currently enabled element) then you should be able to use the "Keyboard.Press" method from .NET to enter anything you want into the text area.

You can also (probably) set the value by modifying the Element.Value property (if your element has a value property). If you post a RanorexSnapshot for the AUT or element we could check that together...

Finally, you mentioned a new issue with Right Click & Popups... You can right click on any element by using the method "Element.Click(MouseButtons.Right)" then interacting with the popup however you want.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

zhuxy2000
Posts: 5
Joined: Fri Oct 26, 2012 3:57 pm

Re: Could I find and select text in Textarea?

Post by zhuxy2000 » Fri Oct 26, 2012 7:57 pm

The text in Ranorex.textareatag is as following:
The Author Name:[~11~]; Age:[~22~]; Address:[~33~];
dfgsd:[~44~]; sdfgsdfgsdfg:[~55~]; sdfg:[~66~];
...

I want to replace [~11~],[~22~],[~33~],[~44~],[~55~],[~66~] with popup menu item to:
ÿNameÿ
The Author Name:[ ÿNameÿ]; Age:[ ÿAgeÿ]; Address:[ÿAddressÿ]
...


You are right: you can use Ranorex.TextAreaTag.TagValue to get the text in Textarea and replace [~11~],[~22~],[~33~],[~44~],[~55~],[~66~] directly in this stringvalue with the parameters in popup menuitem and then use Ranorex.TextAreaTag.Presskeys(stringvalue) to re-set Ranorex.TextAreaTag text

But that is not what I want. What I want is to move the mouse to [~11~], right click mouse and then insert the paramenter directly

The content in this textarea is a template and [ÿNameÿ]; Age:[ ÿAgeÿ]; Address:[ÿAddressÿ] will be replaced by real value in application

Thanks a Lot,

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Could I find and select text in Textarea?

Post by Ciege » Fri Oct 26, 2012 8:46 pm

OK, Again, can you post a RanorexSpy Snapshot? It would help...

And also, once you have the element you can do a "Element.Click(MouseButtons.Right)"...

Since I don't have a RanorexSnapshot to work with, I am only guessing here...

In the TextArea, is all that info in just one element or is there a specific element for each item (i.e. one for name, one for age, etc..)? If a separate element for each, then get that element and right click it. If they are all in one element then you need to do some work such as, determining through code the length of each part of text then clicking in the appropriate X/Y coordinate within the text area.

Please post a RanorexSpy Snapshot.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

zhuxy2000
Posts: 5
Joined: Fri Oct 26, 2012 3:57 pm

Re: Could I find and select text in Textarea?

Post by zhuxy2000 » Tue Oct 30, 2012 8:43 pm

To simplify the problem: could I move mouse to some point in TextArea? or could I move mouse to special string like [~11~] and highlight it?

As I know in some other automation test tools, user can move mouse to some special string like this:[~11~] by using method like this textarea.textexist(stringToFind) or textarea.textselect(stringToFind).

Thanks a lot,

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Could I find and select text in Textarea?

Post by Ciege » Tue Oct 30, 2012 9:54 pm

Since I can't see your element and it's attributes (why I have asked for a RanorexSpy Snapshot several times) I cannot specifically tell you how to call the mouse move...

You can try using the GDI functionality from within Ranorex to work directly with free form text. Not sure if it will do what you want, as I've never used it:
http://www.ranorex.com/search.html?q=gdi
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Could I find and select text in Textarea?

Post by Aracknid » Wed Oct 31, 2012 4:50 pm

I'm going to try to clarify what my co-worker is asking, but I'm going to dumb it down a bit. There's also a pictures to help. :D Don't understand why a snap shot is required?

We've got an HTML TextArea that contains some text, spanning multiple lines. There is a feature in our program (that we need to test) that allows the user to right-click the mouse within the textarea to bring up a menu that contains a list of pre-populate text (how this text appears in the menu is not important). When the text from the menu is selected, it is inserted into the text area in the exact place where the mouse pointer was when we right-clicked.

So our problem is, how do we move the mouse to the exact spot we want, so that when we right-click and insert the text, it will be where we want?

Forget about previous examples. Say I have a textarea with multiple lines like such:
email.jpg
email.jpg (12.62 KiB) Viewed 1643 times
How can I move the mouse to the X (X marks the spot), so that when I right-click the mouse on the X and choose my text, the result will be as such..?
email2.JPG
email2.JPG (7.77 KiB) Viewed 1643 times
Thanks,

Aracknid

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Could I find and select text in Textarea?

Post by Ciege » Wed Oct 31, 2012 5:13 pm

OK, that is making a little more sense to me now...
Don't understand why a snap shot is required?
Well, so that I can see the element, it's attributes and what is given to you to work with.

As for your specific question, I'm not sure there is a built in way for Ranorex to click on a specific character within a text area. So you will probably need to develop some custom code that finds the element and parses the chars yourself to find where the char is you want to click on. You will need to determine the size of the text in code then count over to the appropriate location to know where to click.

This is just my suggestion for how to do it (off the cuff) but there may be other suggestions from Support or other members...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Could I find and select text in Textarea?

Post by artur_gadomski » Thu Nov 01, 2012 10:00 am

We have almost exact scenario. We have a control with text in it where some text is clickable and some not. We would like to find ad click a certain string within a text box.
I haven't looked into a GDI plugin as we only needed to click one text so far so we got away with clicking a pixel but having some generic solution that does that would be nice.
Let me know if you find anything that works.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Could I find and select text in Textarea?

Post by Support Team » Fri Nov 02, 2012 2:57 pm

Hi,

In order to analyze this issue in detail we would need a Ranorex snapshot file or even better a sample solution of that control.

Thanks,
Markus
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Could I find and select text in Textarea?

Post by Aracknid » Fri Nov 02, 2012 3:12 pm

Hi,

This is not an issue, it's a question. We just want to know if it is possible to do what we asked, and if so how. There's nothing special or tricky here. All you need is an HTML page that has an HTML Text Area in it with multi line text. How can you right click the mouse on a specific letter or word in that text area.

Aracknid

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Could I find and select text in Textarea?

Post by Support Team » Mon Nov 05, 2012 10:54 am

Hi,

If this is a normal HTML Text Area it is not possible to click on a specific text, except if you would use coordinate or image based actions.

Regards,
Markus
.
Image