UiElement variables intialization

Can I create an UiElement variable with just the selector values? I don’t want to use any activity to return a UIelement and then store it in a Uielement.

I guess you can.

element = new UiElement()
element.Selector= new Selector("<wnd ctrlname='frmAbc' />")

if you want to add tag (Invoke Method)

element.Selector.AddTag(new SelectorTag("<wnd ctrlname='frm123'))

Should I use this in “Invokecode”? In invode code I am getting error " BC30112:UiPath.core.activities.element is a namespace and cannot be used as expression at Line1

Assign activity.