appium-androiduiautomatorviewer

How to click on Button hiding inside my text box in the form of image at the corner for appium


How to click on Button hiding inside my text box in the form of image at the corner for Appium mobile testing

I need to click on the image. If I click on that image, it will display
one popup and i am unable to find locator separately for the image using UIAUTOMATOR VIEWER because image is inside my textbox so please help me to overcome from this i am not able to proceed.

I am using UIautomator viewer tool avalible to find the locator more unique?


Solution

  • You can use TouchAction and click by coordinates:

    WebElement accountTextBox = driver.findElement(By.id("account_edit_text"));
    Point point = accountTextBox.getLocation();
    int shiftX = accountTextBox.getSize().width - 5; // you can adjust it
    int shiftY = accountTextBox.getSize().height/2;
    new TouchAction(driver)
      .press(point.x + shiftX, point.y + shiftY)
      .waitAction(ofSeconds(1))
      .release()
      .perform();
    

    Also you can use Appium-desktop and try automationName capability set to UIAutomator2 and check what XML its gonna build: it might parse button as separate element.