Forum Discussion
nmrao
9 years agoCommunity Hero
Not sure if you are still looking for it.
Here is the groovy script: The idea is to fetch the values and store them at project level custom properties, so that you can use those values across the project.
def xml ="""<?xml version="1.0" encoding="UTF-8"?>
<config>
<properties>
<property name="DBDriver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="ConnectionString" value="jdbc:oracle:thin:ercore/ercore@localhost:1521:XE"/>
</properties>
</config>"""
def parsedXml = new XmlSlurper().parseText(xml)
def getData = { element, attributeValue ->
parsedXml.'**'.find { it.name() == element && it.@name == attributeValue}.@value.text()
}
def driver = getData('property', 'DBDriver')
def conStr = getData('property', 'ConnectionString')
context.testCase.testSuite.project('DRIVER_CLASS', driver)
context.testCase.testSuite.project('CONNECTION_STRING', conStr)
Use below property expansion where you need those values:
for driver class - ${#Project#DRIVER_CLASS}
for connection string - ${#Project#CONNECTION_STRING}