Finding objects/elements on web page using Selenium RC and Webdriver

Selenium has API’s to get the element ID’s of the web page like Selenium.GetAllButtons(); Selenium.GetAllFields(); and more. If you use the WebDriver than you can use the following code: protected List findElements(By by) { if (!(driver.findElements(by).isEmpty())){“elements ” + by + ” are found”); return driver.findElements(by); }else{ log.warn(“elements ” + by + ” are not […]

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]

Verifying the canonical tag on a web page using Selenium GetLocation

Here is an example to verify the canonical tag on a web page using Selenium GetLocation. The selenium script is written in C# public int CheckCanonicalTag() { int resultcount = 0; string URL = selenium.GetLocation(); if (selenium.IsElementPresent(“//link[@rel=’canonical’ and @href='” + System.Web.HttpUtility.UrlDecode(URL) + “‘]”)) { Console.WriteLine( “Canonical tags is present on the page :” + URL); […]

Using Selenium in a Ajax web application

On an Ajax web application or Ajax feature on web page small sections of the page will update and often the entire webpage will not load. It’s necessary to wait until this ajax process is completed before interacting with sections of the page where content or controls are yet to be rendered. The Ajax application […]

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 […]

Handling IE Security Warning in Selenium RC

When I was running the Selenium RC scripts on IE browser I was getting a Security Warning popup box. Because of this the script was not running and the tests failed. To resolve the issue I used the selenium command selenium.ChooseOkOnNextConfirmation(). This is in Visual Studio C#. In Java its selenium.chooseOkOnNextConfirmation() If you found this […]

Comparing Dates in C# , selenium RC

Example to convert string to date time variable and also compare two date time variable. string Firstdate = selenium.GetText(FirstDate_xp); string Nextdate = selenium.GetText(Nextdate_xp); DateTime date1 = Convert.ToDateTime(Firstdate); DateTime date2 = Convert.ToDateTime(Nextdate); int result = DateTime.Compare(date1, date2); //Compare function returns //0 if both dates are equal //1 if date1 is recent than date2 //-1 if date2 […]