2
votes

I want to run my recorded coded-ui tests in a different copy (different url- same system) my system. I need to change URL string, and i want to do it in my test file (in this case named: d01.cs) Here it is: I have a test name D01.cs, and here's the part i define my parameters:

 public void D01()
        {

            this.UIMap.D01Params.UIRtbTxt1EditText = TestContext.DataRow["test1"].ToString();
            this.UIMap.D01();

In UIMap.Designer i found this:


public class D01Params
 #region Fields
        /// <summary>
        /// Go to web page 'http://localhost:8095/Login.aspx' using new browser instance
        /// </summary>
        public string UIBlankPageWindowsInteWindowUrl = "http://localhost:8095/Login.aspx"

I want to write url as a parameter in my D01.cs file., i want to take it from excel if it's possible.. but i cannot find the correct property to set it. this.UIMAP... does not answer

what should i do? i tried to use: this.UIBlankPageWindowsInteWindowUrl but still not working.

3
Have you tried the answers from this question: stackoverflow.com/questions/13376084/… ? - yonitdm
yes i looked but i couldn't find the answer i'm looking for. The topic suggests to use test editor but i like to take my URL from the excel where i keep my other parameters as well. I mean, run this test, in this URL, with these parameters.. I'm fine with every field but i cant find the correct property to set my URL - Aurora
BTW, i'm using the same browser. in my case, same internet explorer. ı just need to re-write URL. - Aurora

3 Answers

2
votes

As much as I have gained with my experience in CUITs, The CUI Test Builder creates a params class for the methods we generate. If you go to the definition of your method(F12), you'll find this line.

BrowserWindow browser = BrowserWindow.Launch(new System.Uri(this.D01Params.Url));

you can assign your own URL to D01Params with

this.UIMap.D01Params.UIBlankPageWindowsInteWindowUrl = this.TestContext.DataRow["YourNewUrl"].ToString();
this.UIMap.D01Params.UIRtbTxt1EditText = TestContext.DataRow["test1"].ToString();
this.UIMap.D01();
1
votes

you said you wanted to import from excel but i don't see the datasource in your code. did you set DataSource for excel?

eg:

DataSource("System.Data.Odbc", "Dsn=Excel Files;Driver={Microsoft Excel Driver (*.xls)};dbq=|DataDirectory|\\Data.xls;defaultdir=.;driverid=790;maxbuffersize=2048;pagetimeout=5;readonly=true", "Sheet1$", DataAccessMethod.Sequential), TestMethod]

after setting the datasource, you can now access the row of data from the data source.

the syntax to access the colums is as follows:

string paramVal = TestContext.DataRow["Input1"]
0
votes

If you follow the directions in the second answer in the link I sent you you'll find directions on how to get your data from your excel sheet.

Then you could put that data into:

BrowserWindow window = BrowserWindow.Launch(new System.Uri(urlFromExcel));