Need to change XPATH at runtime | Selenium Forum
K
Kiran Posted on 25/09/2020

Hi,

We have write the xpath in different public class like protected String xpathInbox, and initialise in constructor like this.xpathInbox="//div[@id='xxxx']"; and need to change this "xxxx" in another public class within the function.

for above example i used split function but it is not generic also use replace function but value was not change.

Please help me.

Thank you


A
Ashish Thakur Replied on 27/09/2020

1) You should not hard code xpaths. Keep them in properties file

2) At run time you can change but you need to know to which value you need to change. You can then use simple string manipulation functions to change it. String functions like Replace or Substring can help in this

If replace is not working then you need to debug your program and see in variables section - cause of the error