Robotium???????WebElement???
???????????? ???????[ 2015/8/14 11:30:20 ] ????????????????? ??????????
????????????????????е????????WebElement Java bean??
???????????prompt??????е?????????????????Щ????????????????????????н?????????????ε??WebElement??id??text??name????Ρ?
private WebElement createWebElementAndSetLocation(String information?? WebView webView){
String[] data = information.split(";??"); //???????;????????????;????????????????JS??????
String[] elements = null;
int x = 0;
int y = 0;
int width = 0;
int height = 0;
Hashtable<String?? String> attributes = new Hashtable<String?? String>();
try{
x = Math.round(Float.valueOf(data[5]));
y = Math.round(Float.valueOf(data[6]));
width = Math.round(Float.valueOf(data[7]));
height = Math.round(Float.valueOf(data[8]));
elements = data[9].split("\#\$");
}catch(Exception ignored){}
if(elements != null) {
for (int index = 0; index < elements.length; index++){
String[] element = elements[index].split("::");
if (element.length > 1) {
attributes.put(element[0]?? element[1]);
} else {
attributes.put(element[0]?? element[0]);
}
}
}
WebElement webElement = null;
try{
webElement = new WebElement(data[0]?? data[1]?? data[2]?? data[3]?? data[4]?? attributes);//??id??text??name????δ???
setLocation(webElement?? webView?? x?? y?? width?? height);
}catch(Exception ignored) {}
return webElement;
}
/**
* Sets the location of a {@code WebElement}
*
* @param webElement the {@code TextView} object to set location
* @param webView the {@code WebView} the text is shown in
* @param x the x location to set
* @param y the y location to set
* @param width the width to set
* @param height the height to set
*/
private void setLocation(WebElement webElement?? WebView webView?? int x?? int y?? int width?? int height ){
float scale = webView.getScale();
int[] locationOfWebViewXY = new int[2];
webView.getLocationOnScreen(locationOfWebViewXY);
int locationX = (int) (locationOfWebViewXY[0] + (x + (Math.floor(width / 2))) * scale);
int locationY = (int) (locationOfWebViewXY[1] + (y + (Math.floor(height / 2))) * scale);
webElement.setLocationX(locationX);
webElement.setLocationY(locationY);
}
?????????WebElement?????а?????id??text??name????Σ?????????x??y???????????????????????Android?е????View????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11