How to use getTypeInfo method of com.intuit.karate.robot.win.ComLibrary class

Best Karate code snippet using com.intuit.karate.robot.win.ComLibrary.getTypeInfo

Source:ComLibrary.java Github

copy

Full Screen

...76 logger.trace("name: {}, types: {}", name, typeCount);77 }78 for (int i = 0; i < typeCount; i++) {79 String typeName = getName(typeLib, i);80 ITypeInfo typeInfo = getTypeInfo(typeLib, i);81 OaIdl.TYPEATTR typeAttr = getTypeAttr(typeInfo);82 String guid = typeAttr.guid.toGuidString();83 OaIdl.TYPEKIND typeKind = getTypeKind(typeLib, i);84 switch (typeKind.value) {85 case OaIdl.TYPEKIND.TKIND_ENUM:86 case OaIdl.TYPEKIND.ALIGN_GNUC: // UIA_PropertyIds etc. 87 getEnums(typeName, typeInfo, typeAttr);88 break;89 case OaIdl.TYPEKIND.TKIND_INTERFACE:90 case OaIdl.TYPEKIND.TKIND_DISPATCH:91 case OaIdl.TYPEKIND.TKIND_COCLASS:92 getInterfaces(guid, typeName, typeInfo, typeAttr);93 break;94 default:95 if (logger.isTraceEnabled()) {96 logger.trace("==== ignore: {}", typeName);97 }98 }99 }100 }101 //==========================================================================102 //103 private void getInterfaces(String guid, String interfaceName, ITypeInfo typeInfo, OaIdl.TYPEATTR typeAttr) {104 int implCount = typeAttr.cImplTypes.intValue();105 if (implCount > 0) {106 for (int i = 0; i < implCount; i++) {107 OaIdl.HREFTYPE refTypeOfImplType = getRefType(typeInfo, i);108 ITypeInfo refTypeInfo = getRefTypeInfo(typeInfo, refTypeOfImplType);109 String implementingName = getName(refTypeInfo, new OaIdl.MEMBERID(-1));110 ComInterface ci = new ComInterface(interfaceName, implementingName, guid);111 interfaces.put(interfaceName, ci);112 getFunctions(ci, typeInfo);113 if (logger.isTraceEnabled()) {114 logger.trace("==== interface: {}", ci);115 }116 }117 }118 }119 private void getFunctions(ComInterface ci, ITypeInfo typeInfo) {120 OaIdl.TYPEATTR typeAttr = getTypeAttr(typeInfo);121 int count = typeAttr.cFuncs.intValue();122 for (int i = 0; i < count; i++) {123 OaIdl.FUNCDESC funcDesc = getFuncDesc(typeInfo, i);124 int paramCount = funcDesc.cParams.shortValue();125 int vtableId = funcDesc.oVft.intValue();126 int memberId = funcDesc.memid.intValue();127 String[] names = getNames(typeInfo, funcDesc.memid, paramCount + 1);128 String functionName = names[0];129 ComFunction cf = new ComFunction(functionName, vtableId, memberId);130 ci.add(cf);131 getArgs(cf, names, typeInfo, funcDesc);132 }133 }134 private void getArgs(ComFunction cf, String[] names, ITypeInfo typeInfo, OaIdl.FUNCDESC funcDesc) {135 for (int i = 1; i < names.length; i++) {136 OaIdl.ELEMDESC elemdesc = funcDesc.lprgelemdescParam.elemDescArg[i - 1];137 cf.addArg(names[i]);138 }139 }140 private static String[] getNames(ITypeInfo typeInfo, OaIdl.MEMBERID memberId, int maxNames) {141 WTypes.BSTR[] namesRef = new WTypes.BSTR[maxNames];142 WinDef.UINTByReference indexRef = new WinDef.UINTByReference();143 WinNT.HRESULT hr = typeInfo.GetNames(memberId, namesRef, new WinDef.UINT(maxNames), indexRef);144 COMUtils.checkRC(hr);145 int cNames = indexRef.getValue().intValue();146 String[] result = new String[cNames];147 for (int i = 0; i < result.length; i++) {148 result[i] = namesRef[i].getValue();149 OleAuto.INSTANCE.SysFreeString(namesRef[i]);150 }151 return result;152 }153 private static OaIdl.FUNCDESC getFuncDesc(ITypeInfo typeInfo, int index) {154 PointerByReference funcDescRef = new PointerByReference();155 WinNT.HRESULT hr = typeInfo.GetFuncDesc(new WinDef.UINT(index), funcDescRef);156 COMUtils.checkRC(hr);157 return new OaIdl.FUNCDESC(funcDescRef.getValue());158 }159 private static OaIdl.HREFTYPE getRefType(ITypeInfo typeInfo, int index) {160 OaIdl.HREFTYPEByReference refTypeRef = new OaIdl.HREFTYPEByReference();161 WinNT.HRESULT hr = typeInfo.GetRefTypeOfImplType(new WinDef.UINT(index), refTypeRef);162 COMUtils.checkRC(hr);163 return refTypeRef.getValue();164 }165 private static ITypeInfo getRefTypeInfo(ITypeInfo typeInfo, OaIdl.HREFTYPE hrefType) {166 PointerByReference refTypeInfoRef = new PointerByReference();167 WinNT.HRESULT hr = typeInfo.GetRefTypeInfo(hrefType, refTypeInfoRef);168 COMUtils.checkRC(hr);169 return new TypeInfo(refTypeInfoRef.getValue());170 }171 private void getEnums(String enumName, ITypeInfo typeInfo, OaIdl.TYPEATTR typeAttr) {172 int varCount = typeAttr.cVars.intValue();173 Map<String, Integer> keyValues = new LinkedHashMap();174 this.enumKeyValues.put(enumName, keyValues); 175 Map<Integer, String> valueKeys = new HashMap();176 this.enumValueKeys.put(enumName, valueKeys); 177 if (varCount > 0) {178 for (int i = 0; i < varCount; i++) {179 OaIdl.VARDESC varDesc = getVarDesc(typeInfo, i);180 Variant.VARIANT constValue = varDesc._vardesc.lpvarValue;181 Object value = constValue.getValue();182 OaIdl.MEMBERID memberId = varDesc.memid;183 String name = getName(typeInfo, memberId);184 Integer intValue = Integer.valueOf(value.toString());185 keyValues.put(name, intValue);186 valueKeys.put(intValue, name);187 }188 }189 if (logger.isTraceEnabled()) {190 logger.trace("enum: {} - {}", enumName, keyValues);191 }192 }193 private static OaIdl.VARDESC getVarDesc(ITypeInfo typeInfo, int index) {194 PointerByReference varDescRef = new PointerByReference();195 WinNT.HRESULT hr = typeInfo.GetVarDesc(new WinDef.UINT(index), varDescRef);196 COMUtils.checkRC(hr);197 return new OaIdl.VARDESC(varDescRef.getValue());198 }199 private static String getName(TypeLib typeLib, int index) {200 WTypes.BSTRByReference nameRef = new WTypes.BSTRByReference();201 WTypes.BSTRByReference docRef = new WTypes.BSTRByReference();202 WinDef.DWORDByReference helpRef = new WinDef.DWORDByReference();203 WTypes.BSTRByReference helpFileRef = new WTypes.BSTRByReference();204 WinNT.HRESULT hr = typeLib.GetDocumentation(index, nameRef, docRef, helpRef, helpFileRef);205 COMUtils.checkRC(hr);206 String name = nameRef.getString();207 OleAuto.INSTANCE.SysFreeString(nameRef.getValue());208 OleAuto.INSTANCE.SysFreeString(docRef.getValue());209 OleAuto.INSTANCE.SysFreeString(helpFileRef.getValue());210 return name;211 }212 private static String getName(ITypeInfo typeInfo, OaIdl.MEMBERID memberId) {213 WTypes.BSTRByReference nameRef = new WTypes.BSTRByReference();214 WTypes.BSTRByReference docRef = new WTypes.BSTRByReference();215 WinDef.DWORDByReference helpRef = new WinDef.DWORDByReference();216 WTypes.BSTRByReference helpFileRef = new WTypes.BSTRByReference();217 WinNT.HRESULT hr = typeInfo.GetDocumentation(memberId, nameRef, docRef, helpRef, helpFileRef);218 COMUtils.checkRC(hr);219 String name = nameRef.getString();220 OleAuto.INSTANCE.SysFreeString(nameRef.getValue());221 OleAuto.INSTANCE.SysFreeString(docRef.getValue());222 OleAuto.INSTANCE.SysFreeString(helpFileRef.getValue());223 return name;224 }225 private static OaIdl.TYPEKIND getTypeKind(TypeLib typeLib, int index) {226 OaIdl.TYPEKIND.ByReference typeKind = new OaIdl.TYPEKIND.ByReference();227 WinNT.HRESULT hr = typeLib.GetTypeInfoType(new WinDef.UINT(index), typeKind);228 COMUtils.checkRC(hr);229 return typeKind;230 }231 private static ITypeInfo getTypeInfo(TypeLib typeLib, int index) {232 PointerByReference typeInfoRef = new PointerByReference();233 WinNT.HRESULT hr = typeLib.GetTypeInfo(new WinDef.UINT(index), typeInfoRef);234 COMUtils.checkRC(hr);235 return new TypeInfo(typeInfoRef.getValue());236 }237 private static OaIdl.TYPEATTR getTypeAttr(ITypeInfo typeInfo) {238 PointerByReference typeAttrRef = new PointerByReference();239 WinNT.HRESULT hr = typeInfo.GetTypeAttr(typeAttrRef);240 COMUtils.checkRC(hr);241 return new OaIdl.TYPEATTR(typeAttrRef.getValue());242 }243}...

Full Screen

Full Screen

getTypeInfo

Using AI Code Generation

copy

Full Screen

1import com.intuit.karate.robot.win.ComLibrary2import com.sun.jna.platform.win32.COM.util.annotation.ComInterface3import com.sun.jna.platform.win32.COM.util.annotation.ComObject4import com.sun.jna.platform.win32.COM.util.annotation.ComProperty5import com.sun.jna.platform.win32.COM.util.annotation.ComMethod6@ComInterface(iid = "{00020400-0000-0000-C000-000000000046}")7interface IDispatch {8 fun getTypeInfoCount(): Int9 fun getTypeInfo(index: Int, lcid: Int): ITypeInfo10}11@ComInterface(iid = "{00020401-0000-0000-C000-000000000046}")12interface ITypeInfo {13 fun getTypeAttr(): TYPEATTR14 fun getDocumentation(memid: Int, lcid: Int): String15 fun getFuncDesc(index: Int): FUNCDESC16 fun getVarDesc(index: Int): VARDESC17 fun getNames(memid: Int, cMaxNames: Int, lcid: Int): Array<String>18 fun getRefTypeInfo(hreftype: Int): ITypeInfo19 fun addressOfMember(memid: Int, invKind: Int): Int20}21interface TYPEATTR {22 fun getTypeKind(): Int23 fun getFuncCount(): Int24 fun getVarCount(): Int25 fun getImplTypeFlags(index: Int): Int26 fun getNames(): Array<String>27}28interface FUNCDESC {29 fun getNames(): Array<String>30 fun getInvokeKind(): Int31 fun getParams(): Array<Any>32}33interface VARDESC {34 fun getNames(): Array<String>35 fun getVarKind(): Int36 fun getVarValue(): Any37}38@ComInterface(iid = "{00020404-0000-0000-C000-000000000046}")

Full Screen

Full Screen

getTypeInfo

Using AI Code Generation

copy

Full Screen

1def lib = new com.intuit.karate.robot.win.ComLibrary()2def typeInfo = lib.getTypeInfo()3def activeWindow = lib.getActiveWindow()4def activeWindowTitle = lib.getActiveWindowTitle()5def activeWindowClassName = lib.getActiveWindowClassName()6def activeWindowProcessId = lib.getActiveWindowProcessId()7def activeWindowProcessName = lib.getActiveWindowProcessName()8def activeWindowProcessPath = lib.getActiveWindowProcessPath()9def activeWindowProcessVersion = lib.getActiveWindowProcessVersion()10def activeWindowProcessDescription = lib.getActiveWindowProcessDescription()11def activeWindowProcessUserName = lib.getActiveWindowProcessUserName()12def activeWindowProcessCompany = lib.getActiveWindowProcessCompany()13def activeWindowProcessCommandLine = lib.getActiveWindowProcessCommandLine()14def activeWindowProcessStartTime = lib.getActiveWindowProcessStartTime()

Full Screen

Full Screen

getTypeInfo

Using AI Code Generation

copy

Full Screen

1def info = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('Microsoft Internet Explorer.Application')2def ie = com.intuit.karate.robot.win.ComLibrary.getActiveObject('InternetExplorer.Application')3ie.invokeMethod('Visible', true)4def doc = ie.getProperty('Document')5def element = doc.invokeMethod('getElementById', 'main')6def text = element.getProperty('innerText')7ie.invokeMethod('Quit')8assert !ie.invokeMethod('Visible')9ie = com.intuit.karate.robot.win.ComLibrary.getActiveObject('InternetExplorer.Application')10ie.invokeMethod('Visible', true)11doc = ie.getProperty('Document')12element = doc.invokeMethod('getElementById', 'main')13text = element.getProperty('innerText')14ie.invokeMethod('Quit')15assert !ie.invokeMethod('Visible')16ie = com.intuit.karate.robot.win.ComLibrary.getActiveObject('InternetExplorer.Application')

Full Screen

Full Screen

getTypeInfo

Using AI Code Generation

copy

Full Screen

1def com = Java.type('com.intuit.karate.robot.win.ComLibrary')2def info = com.getTypeInfo('MSHTML.HTMLDocumentClass')3def com = Java.type('com.intuit.karate.robot.win.ComLibrary')4def info = com.getMethods('MSHTML.HTMLDocumentClass')5def com = Java.type('com.intuit.karate.robot.win.ComLibrary')6def info = com.getProperties('MSHTML.HTMLDocumentClass')7def com = Java.type('com.intuit.karate.robot.win.ComLibrary')8def info = com.getEvents('MSHTML.HTMLDocumentClass')9def com = Java.type('com.intuit.karate.robot.win.ComLibrary')10def info = com.getEnum('MSHTML.HTMLDocumentClass')11def com = Java.type('com.intuit.karate.robot.win.ComLibrary')12def info = com.getInterface('MSHTML.HTMLDocumentClass')13def com = Java.type('com.intuit.karate.robot.win.ComLibrary')14def info = com.getCoClass('MSHTML.HTMLDocumentClass')15def com = Java.type('com.intuit.karate.robot.win.ComLibrary')16def info = com.getCoClass('MSHTML.HTMLDocumentClass')17def com = Java.type('com.intuit.karate.robot.win.ComLibrary')18def info = com.getCoClass('MSHTML.HTMLDocumentClass')19def com = Java.type('com.intuit.karate.robot.win.ComLibrary')

Full Screen

Full Screen

getTypeInfo

Using AI Code Generation

copy

Full Screen

1import com.intuit.karate.robot.win.ComLibrary2def typeInfo = ComLibrary.getTypeInfo('IUIAutomationElementArray')3import com.intuit.karate.robot.win.ComLibrary4def typeInfo = ComLibrary.getTypeInfo('IUIAutomationElement')5import com.intuit.karate.robot.win.ComLibrary6def typeInfo = ComLibrary.getTypeInfo('IUIAutomation')7import com.intuit.karate.robot.win.ComLibrary8def typeInfo = ComLibrary.getTypeInfo('IUIAutomationCondition')9import com.intuit.karate.robot.win.ComLibrary10def typeInfo = ComLibrary.getTypeInfo('IUIAutomationCacheRequest')11import com.intuit.karate.robot.win.ComLibrary12def typeInfo = ComLibrary.getTypeInfo('IUIAutomationTreeWalker')13import com.intuit.karate.robot.win.ComLibrary14def typeInfo = ComLibrary.getTypeInfo('IUIAutomationEventHandler')15import com.intuit.karate.robot.win.ComLibrary16def typeInfo = ComLibrary.getTypeInfo('IUIAutomationPropertyChangedEventHandler')

Full Screen

Full Screen

getTypeInfo

Using AI Code Generation

copy

Full Screen

1def typeInfo = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.DateTime')2def typeInfo2 = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.Int32')3def typeInfo3 = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.String')4def typeInfo4 = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.Object')5def typeInfo5 = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.Windows.Forms.Form')6def typeInfo6 = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.Windows.Forms.Button')7def typeInfo7 = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.Windows.Forms.Label')8def typeInfo8 = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.Windows.Forms.TextBox')9def typeInfo9 = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.Windows.Forms.CheckBox')10def typeInfo10 = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('System.Windows.Forms.RadioButton')

Full Screen

Full Screen

getTypeInfo

Using AI Code Generation

copy

Full Screen

1* def typeInfo = com.intuit.karate.robot.win.ComLibrary.getTypeInfo('Shell.Application')2* def memberInfo = com.intuit.karate.robot.win.ComLibrary.getMemberInfo(typeInfo, 'NameSpace')3* def memberInfo = com.intuit.karate.robot.win.ComLibrary.getMemberInfo(typeInfo, 'NameSpace', 1)4* def memberInfo = com.intuit.karate.robot.win.ComLibrary.getMemberInfo(typeInfo, 'NameSpace', 1, 1)5* def memberInfo = com.intuit.karate.robot.win.ComLibrary.getMemberInfo(typeInfo, 'NameSpace', 1, 1, 1)6* def memberInfo = com.intuit.karate.robot.win.ComLibrary.getMemberInfo(typeInfo, 'NameSpace', 1, 1, 1, 1)7* def memberInfo = com.intuit.karate.robot.win.ComLibrary.getMemberInfo(typeInfo, 'NameSpace', 1, 1, 1, 1, 1)8* def memberInfo = com.intuit.karate.robot.win.ComLibrary.getMemberInfo(typeInfo, 'NameSpace', 1, 1, 1, 1, 1, 1)9* def memberInfo = com.intuit.karate.robot.win.ComLibrary.getMemberInfo(typeInfo, 'NameSpace', 1, 1, 1, 1, 1, 1, 1)10* def memberInfo = com.intuit.karate.robot.win.ComLibrary.getMemberInfo(typeInfo, 'NameSpace', 1, 1, 1, 1, 1, 1, 1, 1)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Karate automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful