Sample testlink API Client in Python

Source: Internet
Author: User
Tags testlink selenium python

"""testlink API Sample Python Client Implementation"""ImportXmlrpclibclasstestlinkapiclient:#substitute your server URL hereServer_url ="http://localhost/testlink/lib/api/xmlrpc.php"    def __init__(self, Devkey): Self.server=Xmlrpclib. Server (self. Server_url) Self.devkey=DevkeyPrint "Devkey in init:%s"%DevkeydefGettestcaseidbyname (self,devkey): Data= {"Devkey":d Evkey,"Testcasename":"Test Case 1","Testsuitename":"Test Suite 1"}        returnself.server.tl.getTestCaseIDByName (data)defReporttcresult (self, tcid, tpid, status): Data= {"Devkey": Self.devkey,"Tcid": Tcid,"Tpid": Tpid,"Status": status}returnself.server.tl.reportTCResult (data)defGetInfo (self):returnself.server.tl.about ()defSayHello (self):returnSelf.server.tl.sayHello ()defgetprojects (Self, devkey):Print "Devkey:%s"%Devkey Data= {"Devkey":d Evkey}returnself.server.tl.getProjects (data)if __name__=='__main__': Devkey="abc04556463cd813a1ea05caf042d42f"    #substitute your Dev Key hereClient =testlinkapiclient (Devkey)#Get Info about the server    PrintClient.getinfo ()#retval = Client.sayhello ()    #retval = client.getprojects (devkey)retval =client.gettestcaseidbyname (Devkey)Print 'retval:', retval

Please note that you'll need to generate a devkey for the work from within your Testlink installation.

Steps to enable Testlink API via XMLRPC and generate dev key:
    1. Open config.inc.php
    2. Search for /** xml-rpc API availability (disabled by default) */$TLCFG->api->enabled = FALSE;
    3. Change FALSE to True $tlCfg->api->enabled = true;
    4. Save config.inc.php
    5. Login to Testlink UI as admin
    6. Go to ' My Settings '
    7. Under API interface, click ' Generate new key '
    8. Copy the key generated
    9. Substitute your newly generated Devkey in the client program example:client = testlinkapiclient (devkey= "abc04556463cd813a 1ea05caf042d42f ")

This should is sufficient for a test the Testlink xmlrpc API Client server communication. You can then go ahead and use the client program as a library to being called from within your Python test scripts (talking F Rom a Selenium python user perspective). You could does similar implementation with other scripts.

Hope you find this useful.

Sample testlink API Client in Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.