com.qa.automation.android.popupwindow.PopupWindow Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-automation-library Show documentation
Show all versions of android-automation-library Show documentation
Support android ui automaton such as identify Toast and PopupWindow for appium
The newest version!
package com.qa.automation.android.popupwindow;
import android.view.View;
import com.qa.automation.android.AutomationServer;
import com.qa.automation.android.find.Finder;
import com.qa.serializable.Point;
/**
* The type Popup window.
*/
public class PopupWindow {
/**
* Gets element center by text.
*
* @param text the text
* @param index the index
* @return the element center by text
*/
public static Point getElementCenterByText(String text, int index) {
Finder finder = new Finder(AutomationServer.getCurrContext());
View view = finder.getTextView(text, index);
if (view != null) {
int[] location = new int[2];
view.getLocationOnScreen(location);
int centreX = location[0];
int centreY = location[1];
return new Point(centreX, centreY);
}
return null;
}
/**
* Gets element center by id.
*
* @param id the id
* @return the element center by id
*/
public static Point getElementCenterById(String id) {
Finder finder = new Finder(AutomationServer.getCurrContext());
View view = finder.getView(id, 0);
if (view != null) {
int[] location = new int[2];
view.getLocationOnScreen(location);
int centreX = location[0];
int centreY = location[1];
return new Point(centreX, centreY);
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy