Problem with button element

i am new in appium
i configure my environment to work with android in .net window and when i run test
and try to click on login button i got error

info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:“An unknown server-side error occurred while processing the command.”,“origValue”:“unknown error: Failed to read the ‘singleNodeValue’ property from ‘XPathResult’: The result type is not a single node.\n (Session info: chrome=33.0.0.0)\n (Driver info: chromedriver=2.10.289383,platform=Windows NT 6.1 SP1 x86_64)”},“sessionId”:“db887fcf-bd07-49b7-b2d5-b893cdf21edc”}
info: [37m<-- POST /wd/hub/session/db887fcf-bd07-49b7-b2d5-b893cdf21edc/element/0.47826279420405626-4/click [39m[31m500[39m[90m 293.799 ms - 400[39m [90m[39m

my botton look like this

id="submitBtn" class="button1 loginButton col-r highlightEnable" onclick="submitForm();return false;">Login

thanks
frank

How do you get and click on this button?

driver.FindElement(By.Id(“submitBtn”)).Click();

i try also :
AppiumWebElement wel = (AppiumWebElement)driver.FindElementById(“submitBtn”);

wel.Click();

That’s Java, right?
Try to wait until element is visible/clickable before click on it.
What about other elements? Are you able to click on them?

this is c# not java
all other element i can find
this button i can recognize and get his property (class etc…)
only when try to click on him i got this error
also i add some wait time before click on him

Oh, ok. Try to perform click using TouchAction class:

AppiumWebElement button=(AppiumWebElement)driver.FindElementById("submitBtn");
TouchAction action = new TouchAction(driver);
action.Click(button).Perform();

See docs for more information about touch events.

Update: Also, you could try to click on element by executing JS script:

IJavaScriptExecutor JSExecutor = driver as IJavaScriptExecutor;
JSExecutor.ExecuteScript("return $('#submitBtn').click()");

still same problem with click on the button element

Alright. Let’s try this:
AppiumWebElement button=(AppiumWebElement)driver.FindElementById(“submitBtn”);
TouchAction action = new TouchAction(driver);
action.MoveTo(button, 0, 30).Click.Perform();
Not sure about syntax though…

OK thanks lot i will try it

unfortunately i got the same error about server side maby its some how because of the attribute of the div onclick=“submitForm();return false;”

Hi Frank,

Can you try this?

WebElement wb = driver.FindElement(By.Id(“submitBtn”));
wb.submit();

Thanks

i already try it
its doesn’t working
thanks

Hi Frank,

What appium version do you use?
I got the same error when element couldn’t be located.

It may be if you have several elements with same element Id “submitBtn”.

Try next :

  1. First of all set default timeout like this
    appiumDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2));

  2. Then do next
    var elements = appiumDriver.FindElements(By.Id(“submitBtn”)); and check count of elements in list.
    If count is “0” - wrong element id
    If count is “1” - then you are clicking too fast on this element
    If count is >1 - then you have several elements with this id and should use another search criteria.

P.S: the method name with “s” at the end - FindElements.

thanks alot i will try it

i did as you say and got 1 element only, means this is right element ,but when i do this :
elements[0].click; again i got same error and all this check i make in debug mode so i cant understand what does it mean “clicking too fast on this element”
thanks

Okey

Once I had a situation when element was present already but OnClick event was not initialized yet, not ready to execute so it does nothing.

Try to set very long time out to be sure all background requests are finished.
For example Thread.Sleep(15000). Of course this is only for debugging need - later you should find the case of this problem and remove this line.

And if this will not help - than looks like some specific of implementation in your application so might be good idea to ask developers and fix this button. Especially if you have another the same buttons and they work - then it may be problem exactly with with button.

thanks lot
the sleep time doesn’t work so i will ask the developer
but small q :do you think that this button with the property: onclick=“submitForm();return false;”
might cause the problem?

Try next clicks

FindElement(By.LinkText(“Login”))
FindElement(By.XPath("//*[@onclick=‘submitForm();return false;’]"))

P.S. : One more thing. Try to change instruments.