1) Download selenium jar files and run these files using Java command.
2) Download Nunit.
3) Download selenium core dll files for .Net and add it into References.
4) Create new test case in C#
5) Run below code into Nunit
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;
namespace Phoenix.Web.Tests.Controller
{
[TestFixture]
public class SeleniumTest
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:4848/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop();
}
catch (Exception)
{
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void FirstSeleniumTest()
{
# region Previous Smoke Test Code
selenium.Open("/SignIn");
selenium.SetSpeed("9000");
selenium.Type("id=UserName", "ac10");
selenium.Type("id=Password", "password1");
selenium.Click("name=btnSubmitSignIn");
selenium.WaitForPageToLoad("30000");
selenium.Click("link=Create");
selenium.WaitForPageToLoad("30000");
selenium.Type("id=Name", "GREEN VALLEY SCHOOL");
selenium.Type("id=PostCode_1", "KT198DL");
selenium.Click("id=btnFindAddress_1");
} }
}
2) Download Nunit.
3) Download selenium core dll files for .Net and add it into References.
4) Create new test case in C#
5) Run below code into Nunit
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;
namespace Phoenix.Web.Tests.Controller
{
[TestFixture]
public class SeleniumTest
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:4848/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop();
}
catch (Exception)
{
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void FirstSeleniumTest()
{
# region Previous Smoke Test Code
selenium.Open("/SignIn");
selenium.SetSpeed("9000");
selenium.Type("id=UserName", "ac10");
selenium.Type("id=Password", "password1");
selenium.Click("name=btnSubmitSignIn");
selenium.WaitForPageToLoad("30000");
selenium.Click("link=Create");
selenium.WaitForPageToLoad("30000");
selenium.Type("id=Name", "GREEN VALLEY SCHOOL");
selenium.Type("id=PostCode_1", "KT198DL");
selenium.Click("id=btnFindAddress_1");
} }
}
No comments:
Post a Comment