Saving / Printing out element's xpath?

Hello, due to some xpath’s being very long and complex I am trying to find an element by it’s name and then save the xpath to a string variable. I am trying to do the following:

saveXpath = find_element(:name, “buttonName”).xpath

Seems like this is not working even though when I tried saving anything else (label, value, size etc.) it all seemed fine. Can someone help me? Seems like I’m stuck here and I can find anyone trying to do the same thing…

Hmm… I’m not as familiar with the Ruby library, but are you sure Appium returns the Xpath for the element when the element object is built? I recall that Xpath data was only provided when querying for the page source.

I don’t know if it’s possible, but I really hope that there is way. Anyone?