Reputation: 105
My xpath is //[@id='u2001'] It contains value 2001, but i dont want to use direct xpath instead i want to make the value 2001 alone as my input into the xpath, say for example something like .//[@id='ucurrentYearminus15'] here currentYearminus15 is my variable declared
Can someone help me how can insert my variable declared in the ID value? I want to know the syntax of it
Upvotes: 1
Views: 6992
Reputation: 664
Your need is only Java coding. Declare 'currentYearminus15' as a String variable.
String s = "currentYearminus15";
Give your Xpath as driver.findElement(By.xpath("//[@id='u"+s+"']"));
Upvotes: 3