using System;
using System.Text;
using NUnit.Framework;
using Selenium;
namespace GoogleExample
{
[TestFixture]
public class homepage
{
ISelenium selenium;
[SetUp]
//Steps to be executed before execution of all steps
public void setUpTest()
{
selenium = new DefaultSelenium("localhost",4444,"iexplore","http://google.co.in");
//Here 4444 means port no of selenium server, iexplore for IE
selenium.Start(); // To start Selenium server
selenium.SetSpeed("2000"); //To Control the execution speed
selenium.WindowMaximize(); //To Maximize Browser window
}
[TearDown]
//Steps to be executed after execution of all steps
public void tearDownTest()
{
selenium.Stop();
}
[Test]
// Steps to be written to verify the Result Status
public void ResultsStatus()
{
selenium.Open("/"); // open url
selenium.Type("name=q", "Testing"); // Type text in Text Field
selenium.Click("name=btnK"); //click on button with name
//Verifying results status
if ((selenium.IsElementPresent("id=resultStats")))
{
string a = selenium.GetText("id=resultStats"); //Get the text Results output
Console.WriteLine(a); //To display output in the console of NUnit GUI
}
else
{
Console.WriteLine("Results not found"); //To display output in the console of NUnit GUI
}
}
}
}
We need to install NUnit to run the above example.
using System.Text;
using NUnit.Framework;
using Selenium;
namespace GoogleExample
{
[TestFixture]
public class homepage
{
ISelenium selenium;
[SetUp]
//Steps to be executed before execution of all steps
public void setUpTest()
{
selenium = new DefaultSelenium("localhost",4444,"iexplore","http://google.co.in");
//Here 4444 means port no of selenium server, iexplore for IE
selenium.Start(); // To start Selenium server
selenium.SetSpeed("2000"); //To Control the execution speed
selenium.WindowMaximize(); //To Maximize Browser window
}
[TearDown]
//Steps to be executed after execution of all steps
public void tearDownTest()
{
selenium.Stop();
}
[Test]
// Steps to be written to verify the Result Status
public void ResultsStatus()
{
selenium.Open("/"); // open url
selenium.Type("name=q", "Testing"); // Type text in Text Field
selenium.Click("name=btnK"); //click on button with name
//Verifying results status
if ((selenium.IsElementPresent("id=resultStats")))
{
string a = selenium.GetText("id=resultStats"); //Get the text Results output
Console.WriteLine(a); //To display output in the console of NUnit GUI
}
else
{
Console.WriteLine("Results not found"); //To display output in the console of NUnit GUI
}
}
}
}
We need to install NUnit to run the above example.
No comments:
Post a Comment