Skip to main content

Posts

Showing posts from June, 2011

Selenium Tutorial: Selenium Grid 1.0 configuration

I must say I did not have an easy time trying to set up Selenium Grid 1.0 locally. Since I did not have access to multiple machines I was trying to setup hub as well as slave remote control and was following the doc available here . Though documentation is detailed it is tough to have it replicated with your set up. of late I posted about ant build file here and we need to add couple of target to it to be able to work with Selenium grid. I have taken these extra target from the Selenium Grid distribution, these are - Target - "launch-hub" is used to launch grid hub while target "launch-remote-control" is used to launch remote controls along with set of parameters like - host, hubURL etc, which would be serving to hub.

Selenium Tutorial: Ant Build for Selenium Java project

Ant is a build tool which could be used to have your tests running either from command line or from Hudson CI tool. There is detailed documentation available for ant here but probably you need to know only a little part of it for you selenium tests. The essentials which are needed to know are: Project Target (ant execution point and collection of tasks) Tasks (could be as simple as compilation) And there would usually be following targets for Selenium tools - setClassPath - so that ant knows where you jar files are loadTestNG - so that you could use testng task in ant and use it to execute testng tests from ant init - created the build file clean - delete the build file compile - compiles the selenium tests run - executes the selenium tests Here is my project set up for ant -

Selenium Tutorial: Get attribute of an element

With Selenium 1.0 Let us consider Google Search Box for example and its "max length"is to be retrieved. Using xPath -         String var = selenium.getAttribute("//input[@name='q']/@maxlength");         System.out.println(var); Using css locator -                        String var = selenium.getAttribute("css=input[name='q']@maxlength");         System.out.println(var);        With Selenium 2.0 (WebDriver)        Using xPath -         String var = webDriver.findElement(By.xpath("//input[@name='q']")).getAttribute("maxlength")         System.out.println(var); Using css locator -                       String var = webDriver.findElement(By.cssSelector("input[name='q']")).getAttribute("maxlength")         System.out.println(var);

Loving the UI of Google Groups

The new UI of Google Groups has been in existence from a while though I found it only today. I am just in love with how cleaner new UI is and yet Google gives you a chance to file your wish list here

Selenium Tutorial: Pattern Mathing using Selenium

I must confess I have never been admirer of Regular Expression but then there are times you can not escape from it, especially while working on a website which has dynamic contents appeared in static text and you want to validate it. like - "Validate that this text appears and there is 123 here and 456 here" And the test condition is 123 and 456 could be any three digits but number if digits should not be more than three. In a crude way we can at least test this - Assert.assertTrue(selenium.getText("elementLocator").contains("Validate that this text appears and there is")); but what if text goes wrong after "and there is"... what if more than 3 digits appear in text. This is where pattern matching/regular expression comes for our rescue and we can use matches method of String class to achieve same. So the assertion would be - String text = selenium.getText("elementLocator"); Assert.assertTrue(text.matches("Validate

Beginner to Selenium Java Library, How much java to learn?

You have decided to learn Selenium to automate your web application. But not sure where to begin from. There is already one awesome document available on SeleniumHQ to learn Selenium. But what if you have least or no programming experience. And if you are going to use java client driver of Selenium then how much java knowledge you need? Herein I have jotted down some java essentials which are needed in order to used java client library of Selenium. OOPS - Encapsulation, Abstraction, Inheritance, Polymorphism.    Needless to emphasize on their importance in programming. Introduction to Class, instance variable, instance methods, class variable, class method, Object Constructor, Abstract Class, Interface, method overloading, method overriding, Package You definitely need to know when to create a class or interface, how to initialize your instance variables, create methods for test scenarios and bundle your test classes in packages Ctrl Statm

Most cliched Selenium questions...

I see following Selenium questions time and again on multiple Selenium forums (StackOverflow, Google Groups, QAForums) - Does Selenium IDE work with IE? How do I read data from excel using Selenium? Should I use selenium 1 or 2? How do I handle js error using Selenium? How do I handle pop up window using Selenium? Does Selenium support Window application? How do I upload a file using Selenium? Well I am am not posting solution for any of these problems as net is filled with all possible solutions for these scenarios.