How to append browser name for UI tests

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to append browser name for UI tests

shankarkc78@gmail.com
Hi I have some UI tests and some non UI tests.
 Single UI test that runs on 3 browsers(say IE, chrome, ff). I want to prefix testname with the browser name.
Ex :- 
UI testA -> runs on ff, IE, Chrome
NonUI testB

I though of using beforeInvocation and afterInvocation methods. But how would i get the info on which browser was used for test ?

I want test report as below.
ff_testA
IE_testA
Chrome_testA
testB
 
I dont want to pass browser info as parameter. Users will use -DBrowserSpec parameter and pass it.
Any guidance highly appreciated.
Thank you
Shankar KC

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How to append browser name for UI tests

⇜Krishnan Mahadevan⇝
Shankar,
You would need to add a bit more specifics here. 

How does your suite xml file look like ?
It looks like you would want to rely on JVM args [ since you did mention that Users will use -DBrowserSpec parameter and pass it.]
I don’t think you can use this methodology in the first place, because JVM args are visible across tests in the lifespan of the JVM.
 You would need to rely on TestNG parameters from your suite file to get to this level (or) choose data driven approach.

With respect to appending browser names to test methods, you would be able to do it if you build your own reporter [ by implementing Ireporter interface] (or)
Assuming each of your test classes have just 1 @Test annotated test method, you could try implementing ITest interface at each of your test class level and then have the getTestName() method return back whatever you need as the method name.



Thanks and Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


From: shankar KC <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, 1 October 2013 4:46 PM
To: <[hidden email]>
Subject: [testng-users] How to append browser name for UI tests

Hi I have some UI tests and some non UI tests.
 Single UI test that runs on 3 browsers(say IE, chrome, ff). I want to prefix testname with the browser name.
Ex :- 
UI testA -> runs on ff, IE, Chrome
NonUI testB

I though of using beforeInvocation and afterInvocation methods. But how would i get the info on which browser was used for test ?

I want test report as below.
ff_testA
IE_testA
Chrome_testA
testB
 
I dont want to pass browser info as parameter. Users will use -DBrowserSpec parameter and pass it.
Any guidance highly appreciated.
Thank you
Shankar KC

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How to append browser name for UI tests

shankarkc78@gmail.com
In reply to this post by shankarkc78@gmail.com
this is how i am able to do it.

I set the browser spec browserName when test is running.

ITestResult result = Reporter.getCurrentTestResult();

DesiredCapabilities capability = getCapabilities(browserSpecFile, tcID);

result.setAttribute("browser", capability.getBrowserName());

return createRemoteWebDriver(capability, tcID);


Latter in ReportingLister class i acess this property and append it to the name.

 if((m_result.getAttribute("browser") !=null) && (!m_result.getAttribute("browser").toString().isEmpty())){

            methodName = methodName + "_"+m_result.getAttribute("browser").toString() ;

 }


Its working fine for me now.

Thank you

Shankar



On Tue, Oct 1, 2013 at 4:46 PM, shankar KC <[hidden email]> wrote:
Hi I have some UI tests and some non UI tests.
 Single UI test that runs on 3 browsers(say IE, chrome, ff). I want to prefix testname with the browser name.
Ex :- 
UI testA -> runs on ff, IE, Chrome
NonUI testB

I though of using beforeInvocation and afterInvocation methods. But how would i get the info on which browser was used for test ?

I want test report as below.
ff_testA
IE_testA
Chrome_testA
testB
 
I dont want to pass browser info as parameter. Users will use -DBrowserSpec parameter and pass it.
Any guidance highly appreciated.
Thank you
Shankar KC

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/HyMKNXd_B-k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.