Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6027071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:32:15+00:00 2026-05-23T04:32:15+00:00

I have two methods General and SearchTab below. When I look at my report

  • 0

I have two methods General and SearchTab below. When I look at my report file, I see that the values for the General Methods as:

TestName:

TestMachine: Maya

TestUser: Administrator

TestTime: 6/13/2011 12:02

TestStatus: FAIL

TestExpectedResult:

TestActualResult:

TestComments:

TestName, TestExpectedResult, TestActualResult, and TestComments are blank whereas they should have values:

TestName: Test 1: General,

TestExpectedResult: ‘Home’ tab should be present,

TestActualResult: Home tab found

TestComments: Home tab found

Also, the TestStatus should have been PASS instead of FAIL.

It looks like even though I reassigned the values of these variables in the method General, they are still printing the values that were assigned to them inside the constructor.

The problem is the same for the second method SearchTab.

Please help me figure out the problem.

namespace Automation
{
[TestClass]
public class FunctionalTest
{
    public ISelenium Sel;
    public StringBuilder Err;
    public string Report = "C:\Report.XLS";
    public string[] arrTestResults = new string[8];
    public string TestName;
    public string TestMachine;
    public string TestUser;
    public string TestTime;
    public string TestStatus;
    public string TestExpectedResult;
    public string TestActualResult;
    public string TestComments;

    // Constructor
    public FunctionalTest()
    {

        TestName = arrTestResults[0];
        TestMachine = arrTestResults[1] = System.Environment.MachineName.ToString();
        TestUser = arrTestResults[2] = System.Environment.UserName.ToString();
        TestTime = arrTestResults[3] = System.DateTime.Now.ToString();
        TestStatus = arrTestResults[4] = "FAIL";
        TestExpectedResult = arrTestResults[5];
        TestActualResult = arrTestResults[6];
        TestComments = arrTestResults[7];
    }

    public void WriteReport(string[] arrResults)
    {
        int iLastRow, iCnt1;

        if (File.Exists(Report))
        {
            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            Excel.Range range;

            Object misValue = System.Reflection.Missing.Value;
            xlApp = new Excel.Application();
            xlWorkBook = xlApp.Workbooks.Add(misValue);
            xlWorkBook = xlApp.Workbooks.Open(Report, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            range = xlWorkSheet.UsedRange;
            iLastRow = range.Rows.Count;
            for (iCnt1 = 1; iCnt1 < 9; iCnt1++)
            {
                xlWorkSheet.Cells[iLastRow + 1, iCnt1] = arrResults[iCnt1 - 1];
            }
            xlWorkBook.Save();
            xlApp.Quit();
            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);
        }
        else
        {
            Console.WriteLine("Report File " + Report + " does not exist");
        }
    }

    [TestMethod]
    public void General()
    {
        TestName = "Test 1: General";
        TestExpectedResult = "'Home' tab should be present";
        if (Sel.IsElementPresent("TAB_Home")))
        {

                TestStatus = "PASS";
                TestActualResult = "Home tab found";
                TestComments = TestActualResult;
        }
            else
            {
                TestActualResult = "Home tab not found";
                TestComments = TestActualResult;

            }

            //Write to report
            WriteReport(arrTestResults);
        }
    }

    [TestMethod]
    public void SearchTab()
    {
        TestName = "Test 2: Search Tab";
        TestExpectedResult = "Search tab should be present";
        // Assigning TestStatus to FAIL because TestStatus is PASS right now from the previous test method
        TestStatus = "FAIL";

        if (Sel.IsElementPresent("TAB_Search"))
        {
            sActual = "Search Tab found";
            arrTestResults[7] = sActual;
            TestComments = TestActualResult;
            TestStatus = "PASS";
        }
        else
        {
            TestActualResult = "Search tab not found";
            TestComments = TestActualResult;
        }

        //Write to report
        WriteReport(arrTestResults);
    }


}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:32:15+00:00Added an answer on May 23, 2026 at 4:32 am

    Your intialization creates the initial array values and never changes them. You are changing the field values:

    string TestName = "test";
    
    TestName = arrTestResults[0];
    
    // At this point, changing TestName does not affect arrTestResults[0]
    

    Also, you should not use public fields. Rather, you should use properties.

    public string TestName { get; set; }  // auto-property
    

    OR

    private string _testName = string.Empty;
    public string TestName { get { return _testName; } set { _testName = value; }}
    

    You either need to write a setter for your properties that change the array, or better yet use the appropriate fields/properties in your report:

    xlWorkSheet.Cells[iLastRow + 1, 0] = TestName;
    

    Of course, this could be refactored to be much better as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two methods, one that I use to convert an image to a
I have two action methods that are conflicting. Basically, I want to be able
I have these two methods on a class that differ only in one method
I have two methods -a and -b. -a calls sometimes -b, and -b sometimes
I have two methods, the first needs a Map<ItemA, ItemB> the second a Map<ItemA
I have two methods, one called straight after another, which both throw the exact
Is it possible to have two methods with the same name but different parameters
Can somebody explain me one thing. I have two methods in my controller :
I'm hosting my first WCF service in IIS. I have two methods, 1 to
I have two overloaded methods, one with an optional parameter. void foo(string a) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.