TestProject Forum

The Xpath keep changing when execute in whatapps web (chatbot)

My problem is:-

  • using get text to verify the text with XPath element
  • when new message coming, xpath element changing and the current xpath is invalid and not match anymore

i show u the example

A : Hi
B : Welcome to my channels, please choose 1 or 2 - ( Choose Action : Get Text and select the element)
A : 2
B : Please enter your mobile no ( Choose Action : Get Text and select the element)
A : XXXXXXXXXXXXXXX
B: Thank You, We will contact u later ( Choose Action : Get Text and select the element)

After i execute again and i found it will get text = 2 and XXXXXXXXXXXXXX but sometime its working fine, Im not sure it is the action step i take or it has another way. Need urs to help me please .TQ

Hello @kubexstarzofficial

XPaths, are the least preferred way of finding elements.
It changes based on element’s contents and hierarchy and is very fragile, especially hierarchical Xpaths (those that have no conditions on element attributes).

Are you testing the WhatsApp application or one of your own?

Please consider using other locators or enhancing your Xpaths to be more universal, for example, include other attributes of the element, or even its textual contents if possible.

If you can share more details regarding the app structure,
I will be able to help you better.

HI Marat,

Thank you for helping me. The problem I faced before has already been solved. Every time I record, I will make sure every previous whatapps message, I will clear it or discard it first. Then the position of xpath does not change

Will ask again if found any issue. Thanks