Yaniv Eliav Yaniv Eliav - 1 year ago 127
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 Source

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 -

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download