TestProject Forum

Step with parametrized xpath fails with agent 3.0.4 but not 3.0.3

We have a step with the following parametrized xpath: //p[contains(., '{{CompanyName}}')]. This started failing after updating to 3.0.4 agent version. If I revert back to 3.0.3 the step passes again.

These are some lines I collected from the agent logs:
2021-06-30 16:49:19.446 INFO pool-3-thread-5 i.t.a.m.d.o Started processing Step ZPq04fiNEUufubd3M9cw0w (4) in Test 66r14msCDkKuI5FRcVP5Cw 2021-06-30 16:49:19.446 INFO pool-3-thread-5 i.t.a.m.d.o Step Code Block Class Name: io.testproject.agent.codeblocks.driver.element.ClickElement 2021-06-30 16:49:19.449 INFO pool-3-thread-5 i.t.a.m.d.l Step #4/1 'Click {{CompanySelector <Paragraph>}}' in Test 'choose_company_module' on '{}' --> Started 2021-06-30 16:49:19.450 INFO pool-3-thread-5 i.t.a.m.d.o Executing ActionStep: 1.3.4. Click {{CompanySelector <Paragraph>}} 2021-06-30 16:49:19.450 INFO pool-3-thread-5 i.t.a.m.d.o Step designed to sleep 500ms (Before) 2021-06-30 16:49:20.051 INFO pool-3-thread-5 i.t.a.m.d.o Step ZPq04fiNEUufubd3M9cw0w defines a timeout of 35000ms 2021-06-30 16:49:20.075 INFO pool-3-thread-5 i.t.a.m.d.o Using locator [{"byType":"XPATH","byValue":"~?~p[contains(., \u0027{{CompanyName}}\u0027~?~","index":0}] (1/1) for el ement [CompanySelector] in step [1.3.3/0] 2021-06-30 16:49:20.261 INFO pool-4-thread-1 i.t.a.m.d.l Reporting execution progress to manager 2021-06-30 16:49:20.261 INFO pool-4-thread-1 i.t.a.e.a Reporting progress to Agent Manager... 2021-06-30 16:49:55.146 INFO pool-3-thread-5 i.t.a.m.d.o Removing driver implicit timeout
[1625060995,116][INFO]: [8c0101dcccaacd6ef350e8e91db9ebee] RESPONSE FindElements ERROR invalid selector: Unable to locate an element with the xpath expression ~?~p[contains(., '{{CompanyName}}'~?~ because of the following error: SyntaxError: Failed to execute 'evaluate' on 'Document': The string '~?~p[contains(., '{{CompanyName}}'~?~' is not a valid XPath expression. (Session info: chrome=91.0.4472.114)

Seems that some extra characters ~?~ are added to the xpath, but they don’t appear in the generated yaml: value: //p[contains(., '{{CompanyName}}')]

Environment is :

  • Ubuntu 18.04
  • Browser: Chrome v91


Thank you for pointing out this issue,

It will be fixed as part of the next release.