Flash/Flex documentation/code samples

Ask general questions here.
robert_butler
Posts: 24
Joined: Tue Apr 03, 2012 3:05 pm

Flash/Flex documentation/code samples

Post by robert_butler » Tue Apr 03, 2012 3:12 pm

Hi,

New here, trying to do a proof of concept of Ranorex against our Flash/Flex applications. How do I spit out values of text fields? Eventually, I want to save these values to an XLS or CSV file.

This did not work:
FlexElement textTextInput = "/dom[@domain=REMOVEDFORPRIVACY]/body/flexobject/container[@id='view']/element/container/container/container/container[@type='Canvas']/container/container/container[2]/container[@id='_EmployeeSummary_DetailsTile1']/text[@id='valueBox']";
WinForms.MessageBox.Show(textTextInput["value"]);

Thanks,
Bob

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Flash/Flex documentation/code samples

Post by Support Team » Tue Apr 03, 2012 3:37 pm

Hi,

to access the text value of your text adapter you can use the TextValue property:
WinForms.MessageBox.Show(textTextInput.TextValue);
robert_butler wrote:Eventually, I want to save these values to an XLS or CSV file.
Therefore please have a look at e.g. following site:
http://social.msdn.microsoft.com/Forums ... db45627f99


Regards,
Tobias
Ranorex Team

robert_butler
Posts: 24
Joined: Tue Apr 03, 2012 3:05 pm

Re: Flash/Flex documentation/code samples

Post by robert_butler » Tue Apr 03, 2012 3:52 pm

I get the following error?

'Ranorex.FlexElement' does not contain a definition for 'TextValue' and no extension method 'TextValue' accepting a first argument of type 'Ranorex.FlexElement' could be found (are you missing a using directive or an assembly reference?) (CS1061)

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Flash/Flex documentation/code samples

Post by Support Team » Tue Apr 03, 2012 4:27 pm

Hi,

sorry, I haven't seen that you use the FlexElement adapter.
Please try to use the Text adapter instead:
Text textTextInput = "/dom[@domain=REMOVEDFORPRIVACY]/body/flexobject/container[@id='view']/element/container/container/container/container[@type='Canvas']/container/container/container[2]/container[@id='_EmployeeSummary_DetailsTile1']/text[@id='valueBox']";
WinForms.MessageBox.Show(textTextInput.TextValue);
Regards,
Tobias
Ranorex Team

robert_butler
Posts: 24
Joined: Tue Apr 03, 2012 3:05 pm

Re: Flash/Flex documentation/code samples

Post by robert_butler » Tue Apr 03, 2012 4:36 pm

Thank you! That works.

Question, when do I use the FlexElement adapter in the coding? The element would be listed as a FlexElement type adapter in the repository?

robert_butler
Posts: 24
Joined: Tue Apr 03, 2012 3:05 pm

Re: Flash/Flex documentation/code samples

Post by robert_butler » Tue Apr 03, 2012 6:45 pm

Another question:

If I am going to loop through many iterations (test cases) and want to spit out the data values for each test case to the same csv file, is there a way to store these values until the end, then write them all to the csv file?

Thanks!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Flash/Flex documentation/code samples

Post by Support Team » Thu Apr 05, 2012 7:15 pm

Hi,
robert_butler wrote:Question, when do I use the FlexElement adapter in the coding?
With the FlexElement adapter you can set and get most common attributes of the controls as describes in following chapter of our user guide (see heading "How to read/set attributes and styles"):
Flash/Flex Testing
For more details about Ranorex Adapters please have a look at following chapter of our user guide:
Ranorex UI Adapter
robert_butler wrote:If I am going to loop through many iterations (test cases) and want to spit out the data values for each test case to the same csv file, is there a way to store these values until the end, then write them all to the csv file?
The easiest way to fill a csv file with values over several iterations is to append line by line to the csv file.
As shown in the link provided before.

Regards,
Tobias
Ranorex Team

robert_butler
Posts: 24
Joined: Tue Apr 03, 2012 3:05 pm

Re: Flash/Flex documentation/code samples

Post by robert_butler » Thu Apr 05, 2012 8:28 pm

Thanks, I used the following to create the csv file (this link was within your link above):

http://www.blackbeltcoder.com/Articles/ ... files-in-c

I did end up appending, but had to add the following to the code in the article above:

public CsvFileWriter(string filename, bool append)
: base(filename, append)
{
}

My next question is, how do I skip steps (modules or test cases) based on an input variable?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Flash/Flex documentation/code samples

Post by Support Team » Thu Apr 05, 2012 8:37 pm

Hi,

you can start several modules from user code.
Doing so, you can conditional start modules based on variables.
The code might look something like following code snippet:
if (myVar.Equals("True"))
{
  Recording1.Start();
}
else
{
  Recording1.Start();
}
To learn ho to add a variable to user code please have a lok at following chapter of our user guide:
Using Variables with Code Modules

Regards,
Tobias
Ranorex Team

robert_butler
Posts: 24
Joined: Tue Apr 03, 2012 3:05 pm

Re: Flash/Flex documentation/code samples

Post by robert_butler » Thu Apr 05, 2012 9:15 pm

This not working as I expected. Let's assume I have 3 recordings. I add a code module with variable and code below:

if (myVar.Equals("True"))
{
Recording1.Start();
}
else
{
Recording2.Start();
}

I would expect if myVar equals "True" it would go to Recording1 then Recording2, etc. It is not. It performs Recording1 twice.

Then, if myVar does not equal "True" it does go to Recording2, but then it goes back to Recording1. I want to go to Recording2 then Recording3, etc.

Thanks for your help

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Flash/Flex documentation/code samples

Post by Support Team » Fri Apr 06, 2012 7:37 am

Hi,

what does your test suite look like?
Do the recording modules also occur in your test suite and are the checked to be executed?

Please make suer, that the recording modules will not be executed by the test suite but only by the code module.

Regards,
Tobias
Ranorex Team

robert_butler
Posts: 24
Joined: Tue Apr 03, 2012 3:05 pm

Re: Flash/Flex documentation/code samples

Post by robert_butler » Fri Apr 06, 2012 2:54 pm

ok, so group the "conditional" recordings into test case(s) then uncheck the test case and handle by the user code?

i will try that, thanks

robert_butler
Posts: 24
Joined: Tue Apr 03, 2012 3:05 pm

Re: Flash/Flex documentation/code samples

Post by robert_butler » Fri Apr 06, 2012 3:33 pm

so I added a new test case under my existing test case, added the conditional module to that new test case, and unchecked it. however, now the bound variable is no longer working, it is using the default value. it says it is bound.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Flash/Flex documentation/code samples

Post by Support Team » Tue Apr 10, 2012 8:27 am

Hi,

No, what i meant is, that the recordings do not occur in your Test Suite.
The should be started from your code module.

Regards,
Tobias
Ranorex Team

robert_butler
Posts: 24
Joined: Tue Apr 03, 2012 3:05 pm

Re: Flash/Flex documentation/code samples

Post by robert_butler » Tue Apr 10, 2012 2:50 pm

Ok, so if I remove the recording module executed by user code from the test suite, how do I let that recording module use a data variable from data source used in test suite? Can I change recording module to take a parameter?