@Rico_DYellow Some websites e. g. Facebook change their ID and page structure on purpose to avoid automation. On many other websites this simply happens due to dynamic content or page updates in general.
If only the ID of the elements changes see here:
- How to work with the changing ID
- Id and target changes eveytime a page is refreshed
- How to get the Selenium IDE commands to work with dynamic ID's - #2 by Sarat
If the structure changes like from div[2]
to div[3]
as in your case I would try to find a more robust XPath, like @newuserkantu suggested. Sometimes this is possible, but not always!
However, if more changes - or if I am lazy and need a quick solution - I usually simply switch to using visual automation with XClick | (image/OCR). This works always. The drawback is that it is slower than XPath-based macros. But for many macros run time is not a problem, so that is fine.