Could I find and select text in Textarea?
Re: Could I find and select text in Textarea?
So is it possible to get the coordinates of the text we want to click on by doing some sort of pixel based calculation on the text width and height, relative to the top left corner of the HTML text area control?
Re: Could I find and select text in Textarea?
Sure you could figure it out... You need to do some trial and error with your code to determine properly how to find the size of the text area, the size of the text and each character, then do your math to determine where it is you want to click.
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...
Ciege...
- 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?
If I can hijack this thread I'd like Support to look at my snapshot. (If i can't feel free to move this post.)
I have almost the exact same scenario. Text control with some of the text being links. I'd like to be able to know where to click. For me it's a windows application in WinForms I think.
'Sorry, the board attachment quota has been reached'. I'll try to send snapshot to email.
I have almost the exact same scenario. Text control with some of the text being links. I'd like to be able to know where to click. For me it's a windows application in WinForms I think.
'Sorry, the board attachment quota has been reached'. I'll try to send snapshot to email.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Could I find and select text in Textarea?
Hi,
Did you already tried the things Ciege and I mentioned?
As Ciege mentioned you could click on a specific location or as I mentioned you could also try it with a image based click. Here is a link to the location dependent click method: Click Method (location).
If you check the Text attribute of the Text adapter you will also see which Word or Phrase is a link, because they are marked as "Text#LinkId=X", this could help you to locate the links.
Regards,
Markus
Did you already tried the things Ciege and I mentioned?
As Ciege mentioned you could click on a specific location or as I mentioned you could also try it with a image based click. Here is a link to the location dependent click method: Click Method (location).
If you check the Text attribute of the Text adapter you will also see which Word or Phrase is a link, because they are marked as "Text#LinkId=X", this could help you to locate the links.
Regards,
Markus
Re: Could I find and select text in Textarea?
Here is some real quick and dirty code that will find a textarea, determine it's size, determine the size of a character based on some font information, then move the cursor to each character.
This was REALLY quickly done and not perfect but should give you an idea on one way you can proceed. There is no warranty (implied or otherwise) that this will do what you need, but should get you on your way.
This was REALLY quickly done and not perfect but should give you an idea on one way you can proceed. There is no warranty (implied or otherwise) that this will do what you need, but should get you on your way.
Code: Select all
Mouse.DefaultMoveTime = 100;
System.Diagnostics.Process.Start("iexplore.exe", "http://www.w3schools.com/tags/showit.asp?filename=tryhtml_textarea");
Ranorex.WebDocument FooDom = "/dom[@caption='Showit v1.4']";
FooDom.EnsureVisible();
Ranorex.TextAreaTag FooTextArea = FooDom.FindSingle(@".//textarea", 10000);
Font MyFont = new Font("Courier", 4);
Size charSize = TextRenderer.MeasureText("A", MyFont);
int intCols = int.Parse(FooTextArea.Cols);
int intRows = int.Parse(FooTextArea.Rows);
int intX = (FooTextArea.ScreenRectangle.X);
int intY = (FooTextArea.ScreenRectangle.Y);
int intHeight = (FooTextArea.ScreenRectangle.Height);
Mouse.MoveTo(intX, intY);
Thread.Sleep(1000);
for (int r = 1; r < intRows; r++)
{
int TempY = intY + ((intHeight / intRows * r) - (charSize.Height/ 2));
for (int c = 0; c < intCols; c++)
{
int TempX = intX + (c * charSize.Width);
Mouse.MoveTo(TempX, TempY);
Thread.Sleep(100);
}
}
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...
Ciege...
- 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?
@Markus:
We have used coordinate based approach in one case where we use this control. We did not try image based comparison (last time we tried it somewhere else it didn't seem to work and so we don't have much experience with that). Both solutions work only in certain situations so we were looking for some more general solution. We have not tried implementing Ciege's idea yet.
@Ciege:
Thx for the sample.
We have used coordinate based approach in one case where we use this control. We did not try image based comparison (last time we tried it somewhere else it didn't seem to work and so we don't have much experience with that). Both solutions work only in certain situations so we were looking for some more general solution. We have not tried implementing Ciege's idea yet.
@Ciege:
Thx for the sample.
Re: Could I find and select text in Textarea?
As a suggestion for a feature, how about this...
It's easy enough to find the text in a control and select the text, or position the I-beam in the control in a place that you want. If there was a function to "Move the pointer to the selected text" or "Move the pointer to the I-Beam" that would certainly help.
It's easy enough to find the text in a control and select the text, or position the I-beam in the control in a place that you want. If there was a function to "Move the pointer to the selected text" or "Move the pointer to the I-Beam" that would certainly help.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Could I find and select text in Textarea?
Hello,
Thanks for your request.
We will discuss your feature request internally if we implement this in one of our next versions.
Regards,
Markus (T)
Thanks for your request.
We will discuss your feature request internally if we implement this in one of our next versions.
Regards,
Markus (T)