Automation Tips

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']“)

More…

By Pavandeep Puddupakkam on September 8, 2011 | Selenium RC, XPath | 2 comments
Tags: , ,

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 into a single space), so that you can compare the normalized text() and use to filter in a predicate.
Here is the xpath code to validate the above text

try
{
selenium.getText("//test[normalize-space()]").Equals("pass the string here");
}
catch(Exception)
{
}

By Pavandeep Puddupakkam on July 13, 2011 | XPath | A comment?
Tags: , ,

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']“));

More…

By Pavandeep Puddupakkam on July 4, 2011 | XPath | A comment?
Tags: ,

Issues running Selenium Test Scripts on IE8 on Windows 7 

The issue is with your security setting on IE8.
All you need to do is to change the security settings in IE8.
Here are the Steps:
Open IE 8
Go to Tools tab, select Internet options and then select Security tab.
Uncheck the Enable protected mode check box.
Click Apply and OK.

By Pavandeep Puddupakkam on March 9, 2011 | Automation Tips | A comment?
Tags:

Selenium RC Error – SeleniumException: XHR ERROR 

When running the selenium script of a website I got the following error
com.thoughtworks.selenium.SeleniumException: XHR ERROR: URL = http://www.website.com.au/ Response_Code = 400 Error_Message = Bad Request.
The solution was pretty simple. Instead of using the url http://www.website.com.au/ change it to http://website.com.au/. Remove the www.
The reason is because there is no 301 re-direct is not setup for the website.
Originally the setup was – setUp(“http://www.website.com.au/”, “*chrome”);
Changed it to – setUp(“http://website.com.au/”, “*chrome”);

By Pavandeep Puddupakkam on February 15, 2011 | Automation Tips, Selenium RC | 7 comments
Tags: , , ,

The constructor DefaultSelenium(String, String, String, String) is undefined 

I was creating a script in Java and wanted to run the script using TestNG and Eclipse. I was getting the following error when running the script.
The constructor DefaultSelenium(String, String, String, String) is undefined
To solve the issue you will have to make change to the setUp method.
My code was something like this selenium = new DefaultSelenium(“localhost”, “4444″, “*iexplore”, “http://www.google.com/”); having 4444 as a string. I then changed the code to selenium = new DefaultSelenium(“localhost”, 4444, “*iexplore”, “http://www.google.com/”);

By Pavandeep Puddupakkam on December 7, 2010 | Automation Tips, Selenium RC | 2 comments
Tags: , ,