How to locate an element by Xpath with its dynamic title

Example: I have two images
ImageHTMLCode
some_date1 and some_date2 are generated dynamically.
How to locate them using CSS locator ?
click css=img[title*=’since’] : will not work because it won’t
make difference between the two images.

Here is the solution:
If you want to click on the first try this : //IMG[contains(@title,’Critical since’)][1]

Selenium the Agile automation testing tool

Test automation is usually lagging behind development of new functionality. The tools that are used to automate are dependent on the UI and this causes automation of the functionality to start only after the environment and the UI are stable.

Selenium is the test automation tool that helps test below the UI layer. The automation can be done earlier even before the UI is completely ready or matured.

Selenium is language independent and this makes to unique as testers/ developers can start coding as they code the application. You can code the Selenium automation scripts in PHP, Java, C#, Ruby, Python. Selenium uses locator – an element locator on a webpage to identify the element on the webpage.

Ideally its good to code the test scripts in the language the web application is built; by doing so you can integrate the test scripts in your nightly build and help speed up the QA process.

If you found this solution helpful or have something extra to add, feel free to share it here by commenting below.

Issues with Selenium RC and Selenium IDE typeKeys

The typeKeys doesn’t type the ‘dot’ in the text we are entering:
selenium.typeKeys(“assigned_to”, “seleniumwiki.com”);
Your output will be seleniumcom and not selenium.com. The “dot” is missing. This is happening with both Selenium RC and Selenium IDE.
Here is another issue with typeKeys
selenium.typeKeys(“id=username”, “TypeKeys”);
Your output will be “TpeKes” in the textfield. The “Y” is stripped out.
When use “typeKeys” to type “y”, it will active “file” menu in firefox.
Other characters are all OK.

This issue is now fixed when you use the WebDriverBackedSelenium class because you use WebDriver as a backend instead of Selenium Core. The merge with WebDriver for the Sel-IDE side is in progress. But I’ll see what happens in your case but it’s probably in Selenium Core where the problem occurs and not in Selenium IDE. The file concerned is htmlutils.js (function triggerKeyEvent).

Selenium RC with Visual Studio 2010 and NUnit

Here is an example of Selenium RC with Visual Studio 2010 and NUnit. The pass results areĀ  written to the file pass.txt and the failed results to fail.txt.
In this test we are going to openĀ  http://www.google.com/ and the do a search for “selenium rc” and search for the text “Selenium eRemote-Control” on the google search results page.

[csharp]
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 verificationErrors;

[SetUp]

public void SetupTest()

{

selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.google.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());

}

public void writepass(string passtext)

{
System.IO.StreamWriter passmsg = new System.IO.StreamWriter(“C:\\selenium\\pass.txt”, false);

passmsg.WriteLine(“[” + System.DateTime.Now.ToShortDateString() + ” ” + System.DateTime.Now.ToLongTimeString() + “] ” + “Pass: ” + passtext);

//passmsg.WriteLine(passtext);

passmsg.Close();

}
public void writefail(string failtext)

{
System.IO.StreamWriter failmsg = new System.IO.StreamWriter(“C:\\selenium\\fail.txt”, false);

failmsg.WriteLine(“[” + System.DateTime.Now.ToShortDateString() + ” ” + System.DateTime.Now.ToLongTimeString() + “] ” + “Fail: ” + failtext);

//failmsg.WriteLine(failtext);

failmsg.Close();

}
[Test]
public void TheNewTest()

{

selenium.Open(“/”);

selenium.Type(“q”, “selenium rc”);

selenium.Click(“btnG”);

selenium.WaitForPageToLoad(“30000”);

if (selenium.IsTextPresent(“Selenium Remote-Control”))

{
writepass(“the text is present”);

}

else

{
writefail(“the text is not present”);

}

}

}

}
[/csharp]
Submitted by Pavandeep Puddupakkam