Cannot click on a web element in Chrome (possible when Selendroid is used)

Dear all,
I have been working with Appium for a few days and have encountered the following problem. When I navigate to a web page and I want to click on the Login button. When I debug the test then the Login button is found and the click operation is successful but the button is not clicked (otherwise an appropriate modal window would be displayed). When I run the same code with Selendroid on the same port as Appium then everything works properly. Could you please help me to sort this problem out? I am attaching my test in c# and the output from Appium console.

using NUnit.Framework;
using System;
using Selenium_AndroidDriver.Helpers;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Remote;
using System.Collections.Generic;
using OpenQA.Selenium;
using System.Threading;
using System.Drawing;

namespace Selenium_AndroidDriver
{
[TestFixture()]
public class Class6
{
//private RemoteWebDriver driver; //everything commented used with Selendroid
private AppiumDriver driver;

    [TestFixtureSetUp]
    public void BeforeAll()
    {
    
        Uri serverUri = new Uri("http://127.0.0.1:4723/wd/hub");
        //DesiredCapabilities capabilities = OpenQA.Selenium.Remote.DesiredCapabilities.Android();
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.SetCapability("browserName", "Chrome");
        capabilities.SetCapability("platformName", "Android");
        capabilities.SetCapability("deviceName", "HTC One X");
        //driver = new RemoteWebDriver(serverUri, capabilities, TimeSpan.FromSeconds(180));
        driver = new AppiumDriver(serverUri, capabilities, TimeSpan.FromSeconds(180));
    }

    [TestFixtureTearDown]
    public void AfterAll()
    {
            driver.Quit();
    }

    [Test()]
    public void AndroidSimpleTest()
    {
        driver.Navigate().GoToUrl("https://mobile.betway.net/en/sports/#page=1");
        Thread.Sleep(10000);
        var el = driver.FindElementById("LoginIcon");
        el.Click();        
    }
}

}

Appium console:

Checking if an update is available
Update not available
Starting Node Server
error: Couldn’t start Appium REST http interface listener. Requested port is already in use. Please make sure there’s no other instance of Appium running already.

Node Server Process Ended
Starting Node Server
info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“address”:“127.0.0.1”,“fullReset”:true,“logNoColors”:true,“deviceName”:“HTC One X”,“platformName”:“Android”,“platformVersion”:“17”,“automationName”:“Appium”,“browserName”:“Chrome”,“language”:“en”,“locale”:“US”}
info: Console LogLevel: debug
info: → POST /wd/hub/session {“desiredCapabilities”:{“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“HTC One X”}}
info: Client User-Agent string: undefined
info: Set mode: Proxying straight through to Chromedriver
info: [debug] Looks like we want chrome on android
info: [debug] Creating new appium session c6eca78a-2a2b-4e93-9ef2-7a430d5fc677
info: [debug] Using fast reset? false
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it’s already on the device
info: [debug] Checking whether adb is present
info: [debug] Using adb from c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe shell “getprop persist.sys.language”
info: [debug] Current device persist.sys.language: en
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe shell “getprop persist.sys.country”
info: [debug] Current device persist.sys.country: GB
info: [debug] Setting Android Device Country to US
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe shell “setprop persist.sys.country US;”
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe shell “stop; sleep 2; setprop sys.boot_completed 0; start”
info: [debug] waiting for reboot, this takes time.
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe shell “getprop sys.boot_completed”
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device HT24EW120761
info: [debug] Setting device id to HT24EW120761
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s HT24EW120761 wait-for-device
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s HT24EW120761 shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Pushing unlock helper app to device…
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s HT24EW120761 install “C:\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk”
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s HT24EW120761 shell “dumpsys window”
info: [debug] Screen already unlocked, continuing.
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s HT24EW120761 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s HT24EW120761 push “C:\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
info: Starting App
info: [debug] Attempting to kill all ‘uiautomator’ processes
info: [debug] Getting all processes with ‘uiautomator’
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s HT24EW120761 shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s HT24EW120761 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
info: [debug] [BOOTSTRAP] [debug] json loading complete.
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Creating Chrome session
info: [debug] Set chromedriver binary as: C:\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“/data/local/tmp”,“status”:0}
info: [debug] Ensuring Chromedriver exists
info: [debug] Killing any old chromedrivers, running: FOR /F “usebackq tokens=5” %a in (netstat -nao ^| findstr /R /C:"9515 ") do (FOR /F “usebackq” %b in (TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe) do (IF NOT %b==“” TASKKILL /F /PID %b))
info: [debug] No old chromedrivers seemed to exist
info: [debug] Spawning chromedriver with: C:\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] [CHROMEDRIVER] Starting ChromeDriver 2.13.307647 (5a7d0541ebc58e69994a6fb2ed930f45261f3c29) on port 9515
Only local connections are allowed.
info: [debug] Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session",“method”:“POST”,“json”:{“sessionId”:null,“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.chrome”,“androidDeviceSerial”:"HT24EW120761”}}}}
info: [debug] Successfully started chrome session 27e3fb0a289e6f345d50906f5cbc0508
info: [debug] Overriding session id with “27e3fb0a289e6f345d50906f5cbc0508”
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId 27e3fb0a289e6f345d50906f5cbc0508
info: ← POST /wd/hub/session 303 15169.585 ms - 9
info: → GET /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508 {}
info: [debug] Proxying command to 127.0.0.1:9515
info: [debug] Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508",“method”:"GET”}
info: [debug] Proxied response received with status 200: “{"sessionId":"27e3fb0a289e6f345d50906f5cbc0508","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"platform":"ANDROID","rotatable":false,"takesHeapSnapshot":true,"takesScreenshot":true,"version":"39.0.2171.93","webStorageEnabled":true}}”
info: ← GET /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508 200 10.140 ms - 506
info: → POST /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508/url {“url”:“https://mobile.betway.net/en/sports/#page=1”}
info: [debug] Proxying command to 127.0.0.1:9515
info: [debug] Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508/url",“method”:“POST”,“json”:{“url”:"https://mobile.betway.net/en/sports/#page=1”}}
info: [debug] Proxied response received with status 200: {“sessionId”:“27e3fb0a289e6f345d50906f5cbc0508”,“status”:0,“value”:null}
info: ← POST /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508/url 200 12537.520 ms - 72
info: → POST /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508/element {“using”:“id”,“value”:“LoginIcon”,“locator”:“id”}
info: [debug] Proxying command to 127.0.0.1:9515
info: [debug] Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508/element",“method”:“POST”,“json”:{“using”:“id”,“value”:“LoginIcon”,“locator”:"id”}}
info: [debug] Proxied response received with status 200: {“sessionId”:“27e3fb0a289e6f345d50906f5cbc0508”,“status”:0,“value”:{“ELEMENT”:“0.5455560944974422-1”}}
info: ← POST /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508/element 200 119.763 ms - 102
info: → POST /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508/element/0.5455560944974422-1/click {}
info: [debug] Proxying command to 127.0.0.1:9515
info: [debug] Making http request with opts: {“url”:“http://127.0.0.1:9515/wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508/element/0.5455560944974422-1/click",“method”:“POST”,"json”:{}}
info: [debug] Proxied response received with status 200: {“sessionId”:“27e3fb0a289e6f345d50906f5cbc0508”,“status”:0,“value”:null}
info: ← POST /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508/element/0.5455560944974422-1/click 200 471.797 ms - 72
info: → DELETE /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508 {}
info: Shutting down appium session
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“OK, shutting down”,“status”:0}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 32.503
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Killing chromedriver
info: [debug] Chromedriver exited with code null
info: [debug] (killed by signal SIGTERM)
info: [debug] executing cmd: c:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe -s HT24EW120761 shell “am force-stop com.android.chrome”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Cleaning up appium session
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“27e3fb0a289e6f345d50906f5cbc0508”}
info: ← DELETE /wd/hub/session/27e3fb0a289e6f345d50906f5cbc0508 200 1235.435 ms - 72 {“status”:0,“value”:null,“sessionId”:“27e3fb0a289e6f345d50906f5cbc0508”}

Does anybody have a clue?

Have the same issue with Java_client

I do find the element (Log In button) , but when I click on it, nothing happens …

Any Idea how to solve it ?

Hi, my problem was caused by the context. I tested a hybrid application and although I could see the login button then I could not click on that. I have resolved by switching the context. You can find more information here -> A web element is seemingly clicked but in fact no action is performed (Android)

Hope it will help you. Good luck.

Thanks for your help , unfortunately, the context switch doesn’t work for me , I’m switching the context at the beginning of the test , and I do able to recognize the button , but once I click on it , nothing happens , but I do get 200 ‘OK’ response in Appium logs …

Hi, I am facing the same issue and context switch does not help (infact on context switch to NATIVE_APP context i get org.openqa.selenium.NoSuchElementException). Code is pretty straightforward as below. The test passes successfully but click actually never happens.

I could make out for Appium logs that element is located and click request is passed (highlighted in appium logs below). Is this an issue with Appium or Chromedriver? How can i handle this?

Code
@BeforeTest
public void beforeTest() throws MalformedURLException{
capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“deviceName”, “Android”);
capabilities.setCapability(“browserName”, “Chrome”);
capabilities.setCapability(“newCommandTimeout”, 60);
driver = new AndroidDriver(new URL(“http://localhost:4723/wd/hub”), capabilities);
}

@Test
public void test() throws InterruptedException{
    driver.get("testurl");
    Thread.sleep(10000);
    
    driver.findElement(By.xpath("//input[@name='userName']")).sendKeys("testvk1");
    driver.findElement(By.xpath("//input[@name='password']")).sendKeys("test123");
    
    driver.findElement(By.id("button-1041")).click();
}

** Relevant Appium console logs**

info: → POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element {“using”:“xpath”,“value”:“//input[@name=‘password’]”}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element] to [POST http://127.0.0.1:9515/wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element] with body: {“using”:“xpath”,“value”:“//input[@name=‘password’]”}
info: JSONWP Proxy: Got response with status 200: {“sessionId”:“0d48461740583fb4b7e0160a88e55c21”,“status”:0,“value”:{“ELEMENT”:“0.9904485686789031-2”}}
info: JSONWP Proxy: Replacing sessionId 0d48461740583fb4b7e0160a88e55c21 with 0d48461740583fb4b7e0160a88e55c21
info: ← POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element 200 173.860 ms - 102
info: → POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element/0.9904485686789031-2/value {“id”:“0.9904485686789031-2”,“value”:[“test123”]}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element/0.9904485686789031-2/value] to [POST http://127.0.0.1:9515/wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element/0.9904485686789031-2/value] with body: {“id”:“0.9904485686789031-2”,“value”:[“test123”]}
info: JSONWP Proxy: Got response with status 200: {“sessionId”:“0d48461740583fb4b7e0160a88e55c21”,“status”:0,“value”:null}
info: JSONWP Proxy: Replacing sessionId 0d48461740583fb4b7e0160a88e55c21 with 0d48461740583fb4b7e0160a88e55c21
info: ← POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element/0.9904485686789031-2/value 200 719.769 ms - 72
info: → POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element {“using”:“id”,“value”:“button-1041”}
info: JSONWP Proxy: Proxying [POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element] to [POST http://127.0.0.1:9515/wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element] with body: {“using”:“id”,“value”:“button-1041”}
info: JSONWP Proxy: Got response with status 200: {“sessionId”:“0d48461740583fb4b7e0160a88e55c21”,“status”:0,“value”:{“ELEMENT”:“0.9904485686789031-3”}}
info: JSONWP Proxy: Replacing sessionId 0d48461740583fb4b7e0160a88e55c21 with 0d48461740583fb4b7e0160a88e55c21
info: ← POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element 200 149.595 ms - 102
info: → POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element/0.9904485686789031-3/click {“id”:“0.9904485686789031-3”}
> info: JSONWP Proxy: Proxying [POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element/0.9904485686789031-3/click] to [POST http://127.0.0.1:9515/wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element/0.9904485686789031-3/click] with body: {“id”:“0.9904485686789031-3”}
> info: JSONWP Proxy: Got response with status 200: {“sessionId”:“0d48461740583fb4b7e0160a88e55c21”,“status”:0,“value”:null}
info: JSONWP Proxy: Replacing sessionId 0d48461740583fb4b7e0160a88e55c21 with 0d48461740583fb4b7e0160a88e55c21
info: ← POST /wd/hub/session/0d48461740583fb4b7e0160a88e55c21/element/0.9904485686789031-3/click 200 352.401 ms - 72

Hi Did u get your button Click .click () Method Working ,if pls share
the code