Fetching XPath is wrong.

In some points, it’s not fetching the correct xpath.so the step failed. Please suggest any solution for this

3 Likes

Right click on the element that is not showing a “correct xpath” and select Inspect from the pop-up. Do this twice. Now you have the HTML of the element and you can write the xpath yourself. If you need assistance, then paste the HTML here so others can assist you. Read up on how to write pathways.

2 Likes

@raja ! Please Read doc https://docs.katalon.com/docs/create-tests/test-objects/web-test-objects/detecting-objects-with-xpath-in-katalon-studio#:~:text=Absolute%20XPath%20is%20the%20path,HTML%20and%20forward-slash%20(%2F).&text=In%20Katalon%20Studio%2C%20the%20XPath,when%20dealing%20with%20dynamic%20elements.

1 Like

Maybe it’s because the application under test (AUT) sometimes change its path.

For example:
sometimes AUT use path: //*[@id=“rc-tabs-0-panel-ACTIVITY”]/div[2]/div/div/div/div/div/div[2]/table/tbody/tr[1]/td[1]/p
or sometimes AUT use path: //*[@id=“rc-tabs-23-panel-ACTIVITY”]/div[2]/div/div/div/div/div/div[2]/table/tbody/tr[1]/td[1]/p
or sometimes AUT use path: //*[@id=“rc-tabs-8-panel-ACTIVITY”]/div[2]/div/div/div/div/div/div[2]/table/tbody/tr[1]/td[1]/p

For that you should observe path that become static because of certain variation or filter.
So for above case case, @id is always “rc-tabs-”, so it should be:
//*[contains(@id, ‘rc-tabs-’)]/div[2]/div/div/div/div/div/div[2]/table/tbody/tr[1]/td[1]/p

Then, change the path:
to = findTestObject(‘aaaaa/bbbb’)
strXPath = //*[contains(@id, ‘rc-tabs-’)]/div[2]/div/div/div/div/div/div[2]/table/tbody/tr[1]/td[1]/p
to.setSelectorValue(SelectorMethod.XPATH, strXPath)
to.setSelectorMethod(SelectorMethod.XPATH)

1 Like