Friday, May 13, 2011

Fucking Railways

I recently had to travel from alleppy to nagercoil. It was the worst experience i ever had. I don't remember the name of that fucking thing. Anyway it started from Alleppey by around 11:50 am. So i thought to have lunch from the train itself. I have heard that the food served by irctc is really tasty. Why i opted for this specific train bcoz was actually a super fast train.So from Alleppey the next stop will be Kayamkulam , followed by Kollam and Trivandrum.

After a half hour journey it reached some where and waited for a crossing. From there starts the worst part. As it was a really hot day i thought of drinking some water and searched the entire train for person supplying water. It was then i realized that the train had no pantry car. We waited for the crossing for about an hour. No food no water, i was really tired. Same condition for the other passengers. Finally the train started again and before another half hour journey halted for another crossing. Luckily this time it was in a railway station. So i thought of buying some water plus food from the  station. But to my surprise that station had only a ticket counter and a small waiting shed. I searched outside of station but no luck. Same condition. Not even a small shop anyway near. I cursed the whole railways and i got into train. Finally out of exhaustion i slept.

Wednesday, May 11, 2011

Select new window using selenium

Selecting a newly opened window using selenium will me a nightmare for all who are trying to automate using selenium.

 Selenium provides selectWindow(windowID) method for handling this situation. In most cases we wont get the window id. So we are forced to go with other parameters like "title= Title of newly opened page" or "name = Name of Window" etc. Most often window.open method will be provided with a window name. If so we can go for selectWindow("name=window_Name").


If both the above cases cannot be applied go for the code snippet given below.

        Selenium selenium;
        String new_Window = this.driver.getWindowHandle();

        Set<String> wh1 = driver.getWindowHandles();
        selenium.click("Link of window");
        Set<String> wh2 = driver.getWindowHandles();
        wh2.removeAll(wh1);
        new_Window = (String) wh2.toArray()[0];
        selenium.selectWindow(new_Window);

Measure it!

Did you ever wonder or check out for a tool which can be used to measure the length/width of page elements in pixels. Yes, Mozilla has got an addon "Measure it" which does the exact purpose. Just install the addon. Now a icon of  "Measure it" will be rendered in the bottom left corner of  status bar. Just click on it and measure the length of any page element.

Measure it is also available as a Chrome pluigin.