samedi 22 janvier 2022

How to implement C# Reflection code in Python?

I am working on a test automation project that requires the use of reflection with a keyword driven framework. I am having trouble finding Python equivalents for C# methods.

Type t = Type.GetType(FullPathForReflection + Page);
PropertyInfo getPropInfo = t.GetProperty(Object);
var createdClassInstance = Activator.CreateInstance(t, AppiumSession);
WindowsElement getObjectProp = (WindowsElement) getPropInfo.GetValue(createdClassInstance);
keywordClass.processKeywords(Keyword, getObjectProp, Value);

I'm using type() to replace Type.GetType() but can't find any equivalents for GetProperty(object) or GetValue(). Also, I am using t() as a replacement for Activator.CreateInstance and that seems to work.

If anyone could help me find replacement methods or equivalents that would be amazing! Thank you!





Aucun commentaire:

Enregistrer un commentaire