Wednesday, July 2, 2014

Few Quick Walkthrough on How to work with Selenium

Download Selenium tool for Firefox IDE.
http://docs.seleniumhq.org/download/

Once you install Selenium it will appear as small SE icon in web browser. Check the image.
One can record the web flow scenario as per test case and generate code out of it. These code can be used for custom automation test for regression test or integrated or product test.



 
Sample Generated Code file.
namespace SeleniumTests
 
 
{
 
[TestFixture]
public class Code
 
 
{
 
private IWebDriver driver;
private StringBuilder verificationErrors;
private string baseURL;
private bool acceptNextAlert = true;
[SetUp]
public void SetupTest()
 
 
{
 
driver = new FirefoxDriver();
baseURL = "https://www.google.se/";
verificationErrors = new StringBuilder();
 
 
}
 
[TearDown]
public void TeardownTest()
 
 
{
 
try
 
 
{
driver.Quit();
}
 
catch (Exception)
 
 
{
 
// Ignore errors if unable to close the browser
 
 
}
 
Assert.AreEqual("", verificationErrors.ToString());
 
 
}
 
[Test]
public void TheCodeTest()
 
 
{
 
driver.Navigate().GoToUrl(baseURL + "/?gfe_rd=cr&ei=D7CzU9buL-bJ8gfYr4HQDw&gws_rd=ssl#q=Fifa+world+cup");
driver.FindElement(By.Id("gbqfb")).Click();
 
 
}
 

No comments :