• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Newbie Question: How to run a C# file?

jagojago

Junior Member
I'm following the tutorial on WatiN for Visual C# but I can't get it to run. In case you're curious the video tutorial is here: http://watin.org/documentation/getting-started/ and the part where I don't have the same option is 2/3rds the way through. The video shows the presenter clicking on a grey area next to the line of code but I don't have that option. Instead I goto Test --> Run --> Tests in Current Context but it tells me it compiled successfully and won't run because I haven't loaded my test
confused.gif


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using WatiN.Core;

namespace GettingStarted
{
    [TestFixture]
    [RequiresSTA]
    public class Class1
    {
        [Test]
        public void Should_start_automating()
        {
            using (var browser = new IE("google.com")) 
            {
                browser.TextField(Find.ByName("q")).TypeText("Hello Larry");
                browser.Button(Find.ByName("btnK")).Click();
            }
        }
    }
}
 
I've tried to use csc on my cs file such as:

csc Class1.cs but it doesn't work as it seems csc is not able to pick up on WatiN. I've seen it work in Visual Studio itself. Does anyone have any expertise in running cs files in Visual Studio?
 
Usually you compile it into an executable in VS. If you have project open in VS, you should have a Build menu option. The actually executable should be in the debug/bin folder for the project. In order to build the executable, I believe it has to be part of a project, though I've never tried it any way else.
 
Back
Top