Page 1 of 1

Object identification for a line/image inside window view

Posted: Thu Aug 10, 2017 7:46 pm
by manalitatke
Hello,


I wanted to record a text line/ a small image within my entire window.

If i try to create a recording, and do image based validation, it captures the entire window screenshot instead of that particular line/word/image.

The thing is: Since it is a text log file, it also captures the current dates and corresponding time in the text file.
I just want to track the content of the explanation and not the date and time within the lines. Because, this does not help to validate the test case for future use.


Can you please let me know how i can do the image based validation for a word/line/image within a window?


Also, if i need to compare two screenshots, how do i validate the screenshot which is an output of an application currently being tested , and the one which is on a web browser using Ranorex recordings?

I tried referring to the above post: https://www.ranorex.com/forum/comparing ... html#p2176


Wanted to confirm if this can help or any additional image processing functionality has been added to the new version of Ranorex.


Thanks in advance.

Re: Object identification for a line/image inside window view

Posted: Fri Aug 11, 2017 8:38 am
by Stub
Is the text unique? You may be able to setup a regular expression value in the repository item's RxPath that recognises when that particular bit of text exists, or not.

For example, I have a text box that this repository item lets me know the job is currently in progress:

Code: Select all

element[@accessiblename='Summary']/following-sibling::text[@accessiblevalue='Processing...']
And then I wait for this element to exist to know when the processing job has completed:

Code: Select all

element[@accessiblename='Summary']/following-sibling::text[@accessiblevalue>'ETL succeeded']

Re: Object identification for a line/image inside window view

Posted: Fri Aug 11, 2017 9:19 am
by odklizec
Hi,

Using screenshots for validation of log file is (more or less) useless. I would suggest to invest some time for a proper text parsing, either using regular expressions or parsing text to get and validate the text you are interested in and ignore the rest. Using screenshot-based validation is very fragile for such kind of validation. Could you please post a sample log file and description what exactly you want to validate (and what not)? Thanks.

Re: Object identification for a line/image inside window view

Posted: Thu Sep 14, 2017 8:14 pm
by manalitatke
Sure,

i just want to ask one thing:

Is it possible to parse the source code element of web data ( html source) using C# ranorex code modules?


Is Ranorex compatible with html agility pack for C# parsing?


And hereby, i am attaching a screenshot of my dynamic changing elements.
As seen in the screenshot, i want to validate the values for delivered, received kWh, etc.

These values are dynamically changing everyday. So, is there any mechanism to track the current data values using ranorex?
Right now, i have tracked the data for once( default value), declared it as a variable , and set the inner text attribute value of the repository element to be greater than this variable.

This helps my module to report success, however , it would be better if i can set a range for the inner text attribute comparison:

eg: [ @innertext >= default value and @innertext <= defaultvalue+0.5]
where my repository item is declared as a variable and assigned as this default value.

And, any suggestions for tracking them using ranorex code/ available features are welcome!

Re: Object identification for a line/image inside window view

Posted: Wed Sep 20, 2017 1:08 am
by Support Team
Hello Manalitatke,

Thank you for posting these questions in the Ranorex forum.

You asked some good questions.
Is it possible to parse the source code element of web data ( html source) using C# ranorex code modules?
The easiest way I know how to work with the source is by recording a right click on the web page in firefox, and going to the view source button, and the debugger interface in firefox makes it pretty easy to get all the html of the web page, but it is broken into chucks that are the objects, so you need to get the HTML chunks from the InnerText attribute of the objects in the debugger. If you simply record yourself right clicking, going to view source, and then clicking on a few of the chunks, then this will allow you to have the objects with html source in their InnerText attribute in your repository. You can then use GetAttributeValue("InnerText") method in code from our API to work with the chunks, or get a little more complicated and loop over all the child objects of the debugger, and you could then put all the html source text into a single variable. I will research this further, and follow-up on this topic if the team has a better way to work with html source. Since the language is C# then I know you could probably use a text browser to gather all of the source from the command line at one time, but you may want to grab it directly from the browser you are currently testing, so I started with that type of an answer.
Is Ranorex compatible with html agility pack for C# parsing?
I have not worked with the HTML agility pack myself, but Ranorex is a C# IDE, so your C# solutions can work with a whole galaxy of C# libraries. Available online. I checked out the agility pack site, and I did not see anything that would stop me from trying to make this a part of my solution.
is there any mechanism to track the current data values using ranorex?
For this I would likely want to use a database table, and Ranorex is a C# solution, so I would put the data gathered by Ranorex into the database, and that way a day to day comparison can happen. Of course you can flag/fail test if values don't exist, but having a history in a database allows you to poll the database again, and do things like flagging/failing for a certain threshold of changes. The issue here really is the mechanism you're using the store the data, and since Ranorex is a C# solution, then you can store the data almost any imaginable way: text file, csv file, spreadsheet, database, connect to web service, and many more. The question to ask is how do you want to make your data available. That is why I would choose a database to store the data. There are many helpful resources in the forums for SQL connectors and the like.

If you just want to check the current days value for a range, then you will use user code for this operation. Right click your action table to add a new "User Code Method", and name the method. Double click the step and it will take you into user code. You can drag and drop objects from your repository into user code, and then you will have an instance on which you can use the method GetAttributeValue("InnerText").

It would end up being some code like this:

Code: Select all

public void CheckValueForRange()
{
	var myCell = repo.myWebPage.myCell;
	string myString = myCell.Element.GetAttributeValueText("InnerText");
	//string myString = ".372869";  this is the value that passes
	Double stringAsDouble = Convert.ToDouble(myString);
	
	if (stringAsDouble < .372868) {
		Report.Failure("Failure!! Number is lower than range: " + myString);
	} else if (stringAsDouble > .37287) {
		Report.Failure("Failure!! Number is greater than range: " + myString);
	} else {
		Report.Info("Success!! Number is in range: " + myString);
	}
}
If you have any further questions, or questions about anything that you were interested in above, then please do not hesitate to send an email to [email protected], and we will be happy to assist you further.

I look forward to your response.

Sincerely,

- M. Kendall McIntosh
Automation Support Engineer

Re: Object identification for a line/image inside window view

Posted: Thu Sep 21, 2017 10:16 pm
by manalitatke
Sure, thanks a lot for the detailed explanation.

I am currently working on the code approach you suggested. The database is also a good option, but it seems a bit time consuming for formation of the modules.


I will definitely give a try and let you know.


Thanks!