Is there an easy way of getting an ScLocator? We're able to get them in the browser console by "isc.AutoTest.getLocatorWithIndicators()" but this can be cumbersome. It would be great if there was a method to get the locator from the SmartGWT console, from the watch tab. Is something like this possible?
Announcement
Collapse
No announcement yet.
X
-
Consider creating a hotkey that grabs the locator of whatever is under the mouse, or the last thing clicked. You can even copy the locator to the clipboard, so that it's just two keystrokes to stick the locator into the source code of a hand-written test.
You could also just hack something into the Developer Console, but the suggested approach is even quicker.
-
Good suggestion, I was able to get this working. I still think it would be great in the Watch tab in the console, maybe a future feature.
If anyone is interested, here's the code to make this work:
Code:final KeyIdentifier locatorKey = new KeyIdentifier(); locatorKey.setCtrlKey(true); locatorKey.setAltKey(true); locatorKey.setKeyName("W"); Page.registerKey(locatorKey, new PageKeyHandler() { @Override public void execute(final String s) { final Element element = EventHandler.getNativeMouseTarget(); if (element != null) { final QualityIndicatedLocator locator = AutoTest.getLocatorWithIndicators(element); textToClipboard(locator.getLocator()); Notify.addMessage("Locator copied to clipboard"); } } });
Code:private native void textToClipboard(String contents) /*-{ $wnd.navigator.clipboard.writeText(contents); }-*/;
Comment
Comment