selenium测试用JNAUtils3

来源:互联网 发布:python 慕课 pan 编辑:程序博客网 时间:2024/06/05 04:10
// 点击窗口window内的item按钮控件public static void clickItem(String window, String item) {HWND hwnd = JNAUtils.getUnitFrameWnd(window);if (hwnd != null) {List<HWND> items = JNAUtils.getItems(hwnd);for (HWND temp : items) {String name = JNAUtils.getTitle(temp);if (name.equals(item)) {// System.out.println(name);RECT rc = JNAUtils.getWindowRect(temp);int x = (rc.left + rc.right) / 2;int y = (rc.top + rc.bottom) / 2;JNAUtils.setFocus(hwnd);RobotUtils.click(x, y);RobotUtils.click(x, y);}// System.out.println(name);}}}
public static void main(String arg[]) {// RobotUtils.winRun();// RobotUtils.pressKeyByStr("notepad 1.txt");// RobotUtils.submit();// listTitles();HWND hwnd = getUnitFrameWnd("资料");// HWND hwnd = gethwnd();if (hwnd != null) {System.out.println(hwnd);System.out.println("test");RECT rf = getWindowRect(hwnd);System.out.println(rf.left + "," + rf.right + "," + rf.top + ","+ rf.bottom);setFocus(hwnd);System.out.println("test");// RobotUtils.pressKeyByStr("hahaha");rf = getWindowRect(hwnd);System.out.println(rf.left + "," + rf.right + "," + rf.top + ","+ rf.bottom);// listItems(hwnd);hwnd = getACtiveHwnd();System.out.println(hwnd);System.out.println("test");setFocus(hwnd);System.out.println("test");String title = getTitle(hwnd);System.out.println(title);}}}


原创粉丝点击