Appium is not executing click or tap on emulator for element having clickable=false and enabled=true

Viewed 293

I am trying to practice native application automation but stuck due to one issue. The click and tap both are not getting executed on the emulator I tried to open. When inspected the DOM using "uiautomatorviewer", I saw that the clickable attribute and all other attributes were false for the element and only enabled attribute was true. Following is the code snippet I tried to use for tapping on the element.

    import java.io.File;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.List;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.Point;
    
    import org.openqa.selenium.remote.DesiredCapabilities;
    
    import io.appium.java_client.AppiumDriver;
    import io.appium.java_client.MobileDriver;
    import io.appium.java_client.MobileElement;
    import io.appium.java_client.TouchAction;
    import io.appium.java_client.android.AndroidDriver;
    import io.appium.java_client.android.AndroidElement;
    import io.appium.java_client.remote.MobileCapabilityType;
    import io.appium.java_client.touch.TapOptions;
    import io.appium.java_client.touch.offset.PointOption;
    
        public class Appium_Base {
                public static void main(String[] args) throws Exception {
                // TODO Auto-generated method stub
                File f = new File("src");
                File fs = new File(f,"ApiDemos-debug.apk");
                DesiredCapabilities caps=new DesiredCapabilities();
                caps.setCapability(MobileCapabilityType.DEVICE_NAME, "Pratik_Emulator");
                caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "ANDROID");
                caps.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath());
                
                AppiumDriver<MobileElement> driver = new AppiumDriver<>(new URL("http://127.0.0.1:4723/wd/hub"),caps);
                
                Thread.sleep(10000);
                List<MobileElement> elements=driver.findElements(By.className("android.widget.TextView"));
                Thread.sleep(5000);
                Point location = elements.get(0).getLocation();
                TouchAction action = new TouchAction(driver);
                action.tap(PointOption.point(location.x, location.y)).perform();
                
                System.out.println("Clicked");
        
                Thread.sleep(10000);        
            }
        }

The Clicked is printed on console but it was not executed on the emulator. The image of the emulator and appium server log is as follows.Tap_image_appium_server_emulator

I was trying to tap/click on Access'ibility. But nothing happened. I also tried code snippet using click() method as follows instead of tap method.

elements.get(0).click();

But this too did not work. It might be because clickable=false.

Can anyone please help me out with this?

0 Answers
Related