Monday

Parameterize properties file in Java



If you are using a properties file and passing key value pairs, there are instances when you would want to parameterize the values passed. In my case the dynamic xpaths need to be parameteized for more flexibility

Solution: MessageFormat

Steps to achieve this :


  1. Your properties file should have the key value as :
    1. HomePage.DynamicObject.Button=//*[@text=''{0}'' and @width>0] 
  2. In the above statement {0} is the parameter 
  3. In your class file that calls the property
    1. Properties obprop = new Properties();
    2. String Locator= MessageFormat.format(obprop.getProperty(Object_Identifier), params);
    3. where Object_Identifier is HomePage.DynamicObject.Button
    4. and params is the parameter you want to pass

Note:  Within a String, a pair of single quotes can be used to quote any arbitrary characters except single quotes. For example, pattern string "'{0}'" represents string "{0}", not a FormatElement. ...

Any unmatched quote is treated as closed at the end of the given pattern. For example, pattern string "'{0}" is treated as pattern "'{0}'".

Tuesday

Cheatsheet Git

Here is an awesome cheatsheet for the git repo:



P.S: Download the file for clarity

Remove duplicate lines from a file



Problem:

You have two files that you have merged but now there are duplicate lines you want to omit.

Solution:

There are many ways to do this but the easiest is to use this utility:
http://textmechanic.com/Remove-Duplicate-Lines.html

Monday

Eclipse Referenced Libraries disappear



Automating using Java Eclipse? 

Problem:  In Java projects in Eclipse sometimes the folder "Referenced Libraries" disappears from the "Project Explorer" view. All third party jars are shown directly in the root of the project folder

Solution 1:  Bring up the "Package Explorer" view (instead of the "Project Explorer" view).

Solution 2:  Click on the little "down arrow" icon in the top-right corner of the Package Explorer view. In the context menu that appears, one of the items on the menu is "Show 'Referenced Libraries' Node." Click on that menu item.

Thursday

Eclipse Cucumber Plugin - Syntax highlighting not working feature file

If you have just installed the eclipse plugin for cucumber and the feature file steps are not colored then here is the simple solution.

Obviously you have already checked the following:

  1. Plugin Installed correctly
  2. Extension of this file is correct.

Solution: 
What went wrong is that you have accidentally opened the file with 'Text Editor'. All you need to do is change the default to "Editor" 


Monday

Device Enablement in SeeTest



The new feature of device enablement has made iOS mobile automation easy. Now we do not need a provisioning profile !!

Here are the steps tried first hand:

When you add a new device and select the checkbox for instrumented device, you now see a message:


Choose the option for device enablement and click ok, you will see an automated mail sent to you 


 Once you have received the email on confirmation another email will be sent to the support as a request:

Within a few hours you will receive a link to download the .def file!


Happy iOS automation!!!

Friday

Key Events in Android Device Automation


If you are looking to automate your android device there are instances when the automation tool/scripts need to run the adb shell commands to achieve the actions:

If you are using seeTest one of them is:
client.run("adb shell input keyevent 26");

For more commands look at:
http://developer.android.com/reference/android/view/KeyEvent.html


Happy Android automation!