0

I want to create a dynamic test object.

Here's my test object's xpath:

(.//*[normalize-space(text()) and normalize-space(.)='${username}'])[1]/following::span[1]

I want to replace ${username} dynamically in my script. Here's what i've tried:

WebUI.verifyElementPresent(findTestObject('Page_CICIL_adminDashboard/span_Dash', [('username'):varEmail]), 3)

but it throws element not found like this:

com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/Page_CICIL_adminDashboard/span_Dash' located by 'By.xpath: (.//*[normalize-space(text()) and normalize-space(.)='${username}'])[1]/following::span[1]' not found)

Looks like the ${username} variable wasn't replaced by my value correctly.. can you please suggest how to do it correctly?

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
thekucays
  • 568
  • 3
  • 9
  • 32

1 Answers1

1

i finally found a (temporary) workaround for this :D

i fully write the TestObject using script like this

String xpath_spanDash = "(.//*[normalize-space(text()) and normalize-space(.)='" + varEmail + "'])[1]/following::span[1]"
println '>>> the span dash xpath is: ' + xpath_spanDash
TestObject toSpanDash = new TestObject("span_Dash2")
toSpanDash.addProperty("xpath", ConditionType.EQUALS, xpath_spanDash)

and verify the element using this way

// verifying elements
WebUI.verifyElementPresent(toSpanDash, 3)
thekucays
  • 568
  • 3
  • 9
  • 32