Skip to main content

Posts

Showing posts from November, 2011

Selenium: How to verify a hidden div tag exists

Most of the times we do have hidden div tags which need to be verified.  In most of the test designs, the first step towards testing a particular application is to verify that all the elements exist on the application under test.  Example:  Lets say we have a login page which has two text-fields. One for username the other for password. On the page, we also have a hidden div tag which is used by the developer to pass on the login failure message.  Usually its hidden but is set to visible when there is a login failure.  In usual test designs we would want to do something like this at the first step.  1. test all the components exist:  verifyTrue(selenium.isElementExists(LoginPage.username));  verifyTrue(selenium.isElementExists(LoginPage.password)); 2. Then give an incorrect username and password  selenium.type("LoginPage.username","SomeUserName"); selenium.type("LoginPage.password","SomePassword"); 3. Now verify that the label fo

Creating Unique Values using Date

Many a times we are in need of a unique value. The best way to generate a unique value is to use the current date and time combination. We can add both the current date and time to generate a unique value but there are times when we need more precise data to get uniqueness. For instance, you have two jobs running in the same minute then your unique value fails, i.e. when one job is ran at 9.32 AM after 10 milli secs and another is ran at 9.32 AM after 20 milli secs. At this time our unique generator creates the values as: 20111102932 (2011 - 11 - 02 9:32) for both the orders. This is when we will need to include millisecs too. To get the milli secs you can use the following commands in Java: long ldtInMillis = new Date().getTime(); System.out.println("Date - "+ ldtInMillis); Calendar lCalDtMillis = Calendar.getInstance(); System.out.println("Calender - " + lCalDtMillis.getTimeInMillis());