How to assign a variable to a resource file path?
-
Friday, September 07, 2012 5:08 AM
Hi,
I have a resource file in a folder which is a sub folder of another folder (Object_Repository--->Web_Objects--->Page1Web_Objects). So in order to access data in resource file (Page1Web_Objects), I need to use whole hierarchy path like:
Object_Repository.Web_Objects.Page1Web_Objects.XXX.
Can't I assign this hierarchy to a variable and use that variable in order to access data?
I want to write a code as:
public static object Page1Objects = Object_Repository.Web_Objects.Page1Web_Objects; // this gives error.
Properties.Edit(Page1Objects.XXX);
How to achieve this?
Thanks,
Jyothi Priya
All Replies
-
Monday, September 10, 2012 7:08 AM
Hi,
Any help on this??
Thanks,
Jyothi Priya
-
Monday, September 10, 2012 7:48 AMModerator
Hi Jyothi,
Since this forum is to discuss the coded UI test. Just to make this issue clearly, do you mean that you are create a coded UI test for a Web app? We know that we often use the coded UI test to test the UI controls, what real result did you want to test?
Object_Repository.Web_Objects.Page1Web_Objects.XXX.
Is it a control? Do you mean that you want to use the property value of a control?
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
-
Wednesday, September 12, 2012 5:42 AM
Hi Jack,
I'm using coded UI to automate an web application. I'm not using UIMap but instead I'm hand coding coded ui test.
Object_Repository is a folder in my solution. Web_Objects is a sub folder of 'Object_Repository'. I placed a resource file 'Page1Web_Objects' in the sub folder 'Web_Objects', where I'm storing data. So in order to retrieve this data, I need to use whole folder path as 'Object_Repository.Web_Objects.Page1Web_Objects.Data'. What I'm asking is I want to assign this folder path i.e., 'Object_Repository.Web_Objects.Page1Web_Objects' to a variable and make use of that variable to retrieve data in the resource file. How to do that?
-
Thursday, September 13, 2012 6:36 AMModerator
Hi Jyothi,
So you want to write data to a file, am I right?
Actually, there isn’t targeted sample writing data to a file/DB from the test method, but it would be supported as it is in the C#/VB.NET program.
So try to find the examples of reading/write data into a file/DB that would meet your need.
Like this MSDN document “How to: Write Text to a File”:
static void Main(string[] args)
{
string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
StringBuilder sb = new StringBuilder();
foreach (string txtName in Directory.EnumerateFiles(mydocpath,"*.txt"))
{
using (StreamReader sr = new StreamReader(txtName))
{
sb.AppendLine(txtName.ToString());
sb.AppendLine("= = = = = =");
sb.Append(sr.ReadToEnd());
sb.AppendLine();
sb.AppendLine();
}
}
using (StreamWriter outfile = new StreamWriter(mydocpath + @"\AllTxtFiles.txt"))
{
outfile.Write(sb.ToString());
}
}
}
I did some research about it, and I found a similar thread, if possible, you could check it, hope it could help.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator Tuesday, September 18, 2012 1:43 AM

