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]

Validating the text from a text box using Selenium RC

Here is the html code input id=”qu” and the text in the text input box is Selenium Wiki. To validate the text from a text box using Selenium RC you will have to use the Selenium command selenium.getValue(). This will get the value in the location input id=”qu”. selenium.getValue(“//input[@id=’qu’]”) If you found this solution helpful […]

Using Xpath when you have new line text

Here is an example where there are new lines and have to validate if the exact text is displayed in the correct order using xpath. User-agent: * Disallow: /clickthrough.html Disallow: /details.html Disallow: /post-sendtofriend.html Use normalize-space(), which will throw away the leading and trailing whitespace characters (and condense repeating spaces in the middle of the text […]

Using regular expression in Selenium

Here is the xpath I want to use regular expression. Code with out using regular expression: Assert.IsTrue(selenium.IsElementPresent(“ctl00_5hh5_g5656_675gffg042f_tbSearch”)); Code using regular expression: Assert.assertTrue(selenium.isElementPresent(“css=input[id$=’tbSearch’]”)); Alternative is to use contains in the xpath. Here is the example: //input[contains(@id,’tbSearch’)]