Pass parameter to Xpath in Object Repository


Written by:

Assume that we are having  HTML of a dropdown-list below:


Now we want to select item = “Japan” in test script.

Then continue with other items as “China”, “Thailand”, etc.

Correspondent xpath:

//div[@class=’form-group’ and descendant::span[contains(text(),’region’)]]//ul/li[text()=’Japan‘]

//div[@class=’form-group’ and descendant::span[contains(text(),’region’)]]//ul/li[text()=’China‘]

//div[@class=’form-group’ and descendant::span[contains(text(),’region’)]]//ul/li[text()=’Thailand‘]

We can see its xpath is same but differ from value.

One question is that how to pass parameter to xpath above?

Yeah! it is easy to parameterize by using dynamic Xpath with syntax: ${variable}.

Then you can pass parameter in your script by command:

findTestObject(testObjectId, [‘Variable’: ‘Text’])


Reference from:,%20Map%3CObject,%20Object%3E)



Leave a Reply

Your email address will not be published. Required fields are marked *