How can get name of parameter from my XML configuration file in OnFinishSuite method?

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

How can get name of parameter from my XML configuration file in OnFinishSuite method?

Anda Spa
Hello,

I want to return the parameter name from my suite :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Windows10Chrome62CreezContNou" thread-count="2" verbose="2">
  
    
    <listeners>
        <listener class-name="frameworkcontentspeed.Lider.DotTestListener"></listener>
    </listeners>
    

    
    <test name="LoginClientLider1">
        <parameter name="url" value="http://clientlider.speedsites.ro/?page=checkout#register" />
        <parameter name="email" value="[hidden email]" />
        <parameter name="parola" value="" />
        <classes>
            <class name="org.contentspeed.automationtesting.Lider.CreareContNouTest"/>
        </classes>
    </test>
  </suite>

I am lost in the interfaces of TESTNG.

Thanks,

 

--
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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How can get name of parameter from my XML configuration file in OnFinishSuite method?

Krishnan Mahadevan

Heres how you get it from within a Test Method

@Test

public void testTwo() {

    ITestResult testResult = Reporter.getCurrentTestResult();

    XmlTest xmltest = testResult.getTestContext().getCurrentXmlTest();

    //Fetching parameters defined within the <test> tag

    xmltest.getLocalParameters().get("your parameter name goes here");

 

    //this first looks for the parameter definition in <test> and if not found it looks under <suite>

   

    xmltest.getAllParameters().get("your parameter name goes here");

}

Heres how you get it from within a ISuiteListener

class SuiteListener implements ISuiteListener {

 

    @Override

    public void onStart(ISuite suite) {}

 

    @Override

    public void onFinish(ISuite suite) {

        suite.getParameter("your parameter name goes here");

    }

}

 

 

Thanks & Regards

Krishnan Mahadevan

 

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

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

From: <[hidden email]> on behalf of <[hidden email]>
Reply-To: <[hidden email]>
Date: Thursday, February 1, 2018 at 6:24 PM
To: testng-users <[hidden email]>
Subject: [testng-users] How can get name of parameter from my XML configuration file in OnFinishSuite method?

 

Hello,

 

I want to return the parameter name from my suite :

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Windows10Chrome62CreezContNou" thread-count="2" verbose="2">

  

    

    <listeners>

        <listener class-name="frameworkcontentspeed.Lider.DotTestListener"></listener>

    </listeners>

    

 

    

    <test name="LoginClientLider1">

        <parameter name="url" value="http://clientlider.speedsites.ro/?page=checkout#register" />

        <parameter name="email" value="[hidden email]" />

        <parameter name="parola" value="" />

        <classes>

            <class name="org.contentspeed.automationtesting.Lider.CreareContNouTest"/>

        </classes>

    </test>

  </suite>

 

I am lost in the interfaces of TESTNG.

 

Thanks,

 

 

--
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
https://groups.google.com/group/testng-users.
For more options, visit
https://groups.google.com/d/optout.

--
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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How can get name of parameter from my XML configuration file in OnFinishSuite method?

Anda Spa
In reply to this post by Anda Spa
Thanks,



joi, 1 februarie 2018, 14:54:06 UTC+2, [hidden email] a scris:
Hello,

I want to return the parameter name from my suite :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">
<suite name="Windows10Chrome62CreezContNou" thread-count="2" verbose="2">
  
    
    <listeners>
        <listener class-name="frameworkcontentspeed.Lider.DotTestListener"></listener>
    </listeners>
    

    
    <test name="LoginClientLider1">
        <parameter name="url" value="<a href="http://clientlider.speedsites.ro/?page=checkout#register" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fclientlider.speedsites.ro%2F%3Fpage%3Dcheckout%23register\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEqRh7vs_vam4SYvncLF1vpm7d11g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fclientlider.speedsites.ro%2F%3Fpage%3Dcheckout%23register\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEqRh7vs_vam4SYvncLF1vpm7d11g&#39;;return true;">http://clientlider.speedsites.ro/?page=checkout#register" />
        <parameter name="email" value="[hidden email]" />
        <parameter name="parola" value="" />
        <classes>
            <class name="org.contentspeed.automationtesting.Lider.CreareContNouTest"/>
        </classes>
    </test>
  </suite>

I am lost in the interfaces of TESTNG.

Thanks,

 

--
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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.