Selenium Rc
I was using selenium rc and ruby a few months back.
Today when I tried using it, there are a lot of changes and there is no documentation.
Let me go through the differences between old and new.
Old
Download selenium remote control. It is a zip file. Unzip the file.
Now you will find the selenium server ( a jar file which u have to run from the command prompt) and the selenium client for ruby ( a driver file in the respective language, ie for ruby, u may expect selenium.rb)
Just copy selenium.rb to the project . In Netbeans IDE, u have to right click project, select properties, add to project ( jar or folder) and select the appropriate client driver.
New
In the ruby client folder, no selenium.rb exists. A doc folder is present which asks us to install the selenium gem.
Great, now it is a gem, but what am i supposed to do after that. I installed the gem.
When i run the ruby tests, a lot of errors come up. When i google for these errors, no help comes up.
Dot net to the rescue
I created a "test project" in visual studio 2008. Added the references, (by right clicking references and selecting browse -> selecting all the dlls inside the dot net client driver folder (inside remote control) ) and then copy pasted the code from selenium ide. Wonder of wonders! it works!!
From the code window, here is a sample test which verifies some basic test on the application ui.
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;
namespace SeleniumTests
{
[TestFixture]
public class NewTest
{
private ISelenium selenium;
private StringBuilder verificationErrorsa;
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://buytickets.thetrainline.com/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void TheNewTest()
{
selenium.Open("/");
try
{
Assert.IsTrue(selenium.IsTextPresent("Buy train tickets"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}
selenium.Click("dnn_ctr24339_TissipGenericForm_LoginStatusAndRedirector.LoginStatus");
selenium.WaitForPageToLoad("30000");
try
{
Assert.IsTrue(selenium.IsTextPresent("Log in"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}
selenium.Click("//a[@id='dnn_ctr24339_TissipGenericForm_LoginStatusAndRedirector.Home']/span");
selenium.WaitForPageToLoad("30000");
try
{
Assert.IsTrue(selenium.IsTextPresent("Buy train tickets"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}
}//end of new test
}
}
Today when I tried using it, there are a lot of changes and there is no documentation.
Let me go through the differences between old and new.
Old
Download selenium remote control. It is a zip file. Unzip the file.
Now you will find the selenium server ( a jar file which u have to run from the command prompt) and the selenium client for ruby ( a driver file in the respective language, ie for ruby, u may expect selenium.rb)
Just copy selenium.rb to the project . In Netbeans IDE, u have to right click project, select properties, add to project ( jar or folder) and select the appropriate client driver.
New
In the ruby client folder, no selenium.rb exists. A doc folder is present which asks us to install the selenium gem.
Great, now it is a gem, but what am i supposed to do after that. I installed the gem.
When i run the ruby tests, a lot of errors come up. When i google for these errors, no help comes up.
Dot net to the rescue
I created a "test project" in visual studio 2008. Added the references, (by right clicking references and selecting browse -> selecting all the dlls inside the dot net client driver folder (inside remote control) ) and then copy pasted the code from selenium ide. Wonder of wonders! it works!!
From the code window, here is a sample test which verifies some basic test on the application ui.
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;
namespace SeleniumTests
{
[TestFixture]
public class NewTest
{
private ISelenium selenium;
private StringBuilder verificationErrorsa;
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://buytickets.thetrainline.com/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void TheNewTest()
{
selenium.Open("/");
try
{
Assert.IsTrue(selenium.IsTextPresent("Buy train tickets"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}
selenium.Click("dnn_ctr24339_TissipGenericForm_LoginStatusAndRedirector.LoginStatus");
selenium.WaitForPageToLoad("30000");
try
{
Assert.IsTrue(selenium.IsTextPresent("Log in"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}
selenium.Click("//a[@id='dnn_ctr24339_TissipGenericForm_LoginStatusAndRedirector.Home']/span");
selenium.WaitForPageToLoad("30000");
try
{
Assert.IsTrue(selenium.IsTextPresent("Buy train tickets"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}
}//end of new test
}
}
Hey Manoj, Please cancel the auto-forward or the filter in your gmail which is forwarding mails to my inbox. Your mails are overflowing my inbox.
ReplyDelete