This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 3
Sep 2017

Q1: I am trying to automate Amazon Hybrid App where identified the web element from Home screen which is not displayed in Mobile screen. So For that, I have scroll the screen down to up. But Appium is able to identify the web element even not displayed in the Mobile screen.
How is it possible in Mobile automation?

driver.find_element_by_xpath("//android.view.View1[@content-desc = “ANY ELEMENT CONTENT”]")

Q2: Can we identify UI elements through UI Automater Viewer for Hybrid App (Native and Web element both)? Currently I am able to identify both using UI Automater Viewer. Pl confirm.

Appium: 1.6.4
Language: Python
SDK: 23
OS: Android

Pl help me to solve above problems and let me know, if any query.

  • created

    Sep '17
  • last reply

    Nov '17
  • 2

    replies

  • 427

    views

  • 2

    users

  • 1

    link

@muditgupta87 well check element coordinates yourself :-). just a sample easier to understand


import io.appium.java_client.MobileBy;
import io.appium.java_client.MobileElement;
import org.openqa.selenium.WebElement;

        // Java
        int screenWidth = driver.manage().window().getSize().getWidth();
        int screenHeight = driver.manage().window().getSize().getHeight();
        MobileElement el = (MobileElement) driver.findElement(MobileBy.xpath("//android.view.View[@content-desc = “ANY ELEMENT CONTENT”]"));
        
        int elCenter_X = el.getCenter().getX();
        int elCenter_Y = el.getCenter().getY();
        
        if (elCenter_X > 0 && elCenter_X < screenWidth) {
            if (elCenter_Y > 0 && elCenter_Y < screenHeight) {
                // we are on screen :-)
            }
        }
2 months later