Yaniv Eliav Yaniv Eliav - 5 months ago 14
Android Question

How to press an Element by Xpath

I would like to click an Element (in Appium, using Selenium) by following hierarchy:



(1)LinerLayout --> android.widget.LinearLayout
(0)RelativeLayout --> android.widget.RelativeLayout
(0)ImageView --> android.widget.ImageView





I have tried to use the following Xpath but without any success.



[FindsBy(How = How.XPath, Using = "//'android.widget.LinearLayout[1]/android.widget.RelativeLayout[0]/android.widget.ImageView[0]'")]
public IList<IWebElement> SearchStreetButton { get; set; }




Answer

As mentioned in the comments as well to resolve such a problem, the X-Path shall not include the single inverted commas unless used with contains or any other string operation -

Changing the x-path as follows shall work -

"//android.widget.LinearLayout[1]/android.widget.RelativeLayout[0]/android.wid‌​get.ImageView[0]"