Reputation: 33
I have recently started using selenium web driver.Can you please tell me which is the best approach -I have to assert a form with different fields -should i use TestNG class or framework(reading data from excel).
Thanks
Upvotes: 1
Views: 122
Reputation: 651
Reflection is cool way to do random action testing. For example, create a String[] that has all of your non-parameterized page methods (menu clicks, button pushes, typing random text, etc). Select from your array randomly and call something like this:
static public void executePageMethod( YourWebPageClass page, String methodName ) {
java.lang.reflect.Method method = null;
try {
method = page.getClass().getMethod( methodName );
} catch ( SecurityException e ) {
Debug( "SecurityException" );
} catch ( NoSuchMethodException e ) {
Debug( "NoSuchMethodException" );
}
assert (method != null);
try {
method.invoke( page );
} catch ( IllegalArgumentException e ) {
Debug( "IllegalArgumentException" );
} catch ( IllegalAccessException e ) {
Debug( "IllegalAccessException" );
} catch ( InvocationTargetException e ) {
Debug( "InvocationTargetException" );
}
}
We use this for "wandering user" testing for our web apps.
Upvotes: 1
Reputation: 193338
As you have recently started using Selenium WebDriver the suggestion of Best Approach would be entirely based on opinions, rather than facts, references, or specific expertise.
However, personally I have found that, starting with a Selenium Hybrid Framework i.e. reading data from excel will help you to understand how the core function()
calls works and a detailed understanding of Java Reflection API.
With the core understanding of Java Reflection API when you will move towards integrating frameworks e.g. TestNG your understanding of the implemented APIs will be more stronger and implementation will be much more easier.
Upvotes: 1