throws Exception {
// web stuff.
//scrollIntoViewIfNeeded();
Point po = findPosition();
Dimension dim = getInspector().getSize();
int webPageWidth = getInspector().getInnerWidth();
if (dim.getWidth() != webPageWidth) {
log.fine("BUG : dim.getWidth()!=webPageWidth");
}
Criteria c = new TypeCriteria(UIAWebView.class);
String json = c.stringify().toString();
StringBuilder script = new StringBuilder();
script.append("var root = UIAutomation.cache.get('1');");
script.append("var webview = root.element(-1," + json + ");");
script.append("var webviewSize = webview.rect();");
script.append("var ratioX = 1.0 * webviewSize.size.width / " + dim.getWidth() + ";");
script.append("var ratioY = 1.0 * webviewSize.size.height / " + dim.getHeight() + ";");
int top = po.getY();
int left = po.getX();
// switch +1 to +2 in next, with +1 some clicks in text fields didn't bring up the
// keyboard, the text field would get focus, but the keyboard would not launch
// also with this change 17 miscellaneous selenium tests got fixed
switch (position) {
case TOP_LEFT: {
script.append("var top = (" + top + "*ratioX);");
script.append("var left = (" + left + "*ratioY);");
break;
}
case CENTER: {
Dimension size = getSize();
script.append("var top = (" + top + " + " + size.getHeight() + " / 2) * ratioX;");
script.append("var left = (" + left + " + " + size.getWidth() + " / 2) * ratioY;");
break;
}
}
script.append("var x = left;");