Appium get xpath from element?

I have code that retrieves a static text element for me, but what I want to do is get the xpath of this element as a string. I use ruby. At this point, I have an array of elements that I have already extracted. Below I tried, but no luck.

elements.each do |element|

  if element.attribute("name").include? vProblem
    p "Problem found, retrieving xpath..."

    # Neither of these work
    p "Problem xpath is: " + element.attribute("xpath").to_s
    p "Problem xpath is: " + element.xpath.to_s

  end
end
+4
source share
1 answer

I do not believe that there is a simple method or parameter to call that will give you the xpath value. You must determine this yourself. To do this, swipe through all the elements of the page until you find one that (A) matches the class of the item you are looking for and (B) matches the name / value of the item.

, , , , . , .

+1

Source: https://habr.com/ru/post/1612466/


All Articles