1

I have an xpath:

//*[@id='00QE000000gQ9fv_ACTION_COLUMN']/a[2]/span

in this xpath 00QE000000gQ9fv is dynamic and _ACTION_COLUMN remains the same. I stored 00QE000000gQ9fv in a String variable as recordId i.e:

String recordId = 00QE000000gQ9fv 

Now I want an xpath that contains recordId variable.

1

1 Answer 1

4

Create a string variable and use it (for example) as follows:

string strMyXPath = "//*[@id='" + recordId + "_ACTION_COLUMN']/a[2]/span";
driver.FindElement(By.XPath(strMyXPath)).Click();
1
  • this works perfectly right and working fine for my code. May 27, 2023 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.