Can't find the element using id but working fine with xpath

I am trying to find one element using id=search_icon, it is giving me no element found, but when I am using this xpath=//*[@resource-id=‘search_icon’], it is working fine. What could be the possible issue here?


“id” and “resource-id” are not the same thing.

For example the reply button on this page has simply “id” which could be used as you expected:

For your case I think you simply just need to use:

resource-id=search_icon

Edit:

I may have jumped the gun a bit, didn’t realize this was Appium. Presuming you are using AppiumLibrary then indeed resource-id should map to id like you say…

Thanks for the reply.

Yes I am using AppiumLibrary but id is not working. Still trying to figure out the issue. It is working fine if I am using it as xpath=//*[@resource-id=‘search_icon’]. Don’t know the exact issue.

Btw this is a react native application.