How to invoke other activities inside "Invoke Code" activity?

code
studio
invoke

#1

I am checking if a button exists in a webpage.

If it exists i have to do some operations.

Here, i m trying to make use of “invoke code” activity and perform my tasks. Do we have any way to invoke other exisiting activities inside the InvokeCode activity in UiPath 2017?

eg: Inside invoke code

if(btnExist)
{
//Perform click
}

Can I use click activity inside the invoke code?

–Sudhakar


#2

Hi Sudhakar,

Invoke Code is mainly for .Net methods that return null.
So why don’t you use Image/Element exists -> If/Flow Decision -> Click activity?

Maybe it will work if somehow you would use the apps’ API and run some code for an activity like Click. But never tried this, for me it’s easier with the existing activities.


#3

Something like this should work in code activity (did not test). Also not sure if it effects the existing workflow process since we are invoking sub activity. Folks who are using 2017.1 can confirm.

click = new Uipath.Core.Activities.Click()
click.Target.Selector ="<html title='Tryit Editor v3.5' /><webctrl aaname='Click me' tag='BUTTON' type='submit' />"
click.ClickType = ClickType.CLICK_SINGLE
activity = new WorkflowInvoker(click)
activity.Invoke()

#4

Thanks vaidya!
Will check this.


#5

After minimal modification, it worked like a charm !!!

click.Target.Selector ="//MySelectorHere"
click.ClickType = ClickType.CLICK_SINGLE
activity = New WorkflowInvoker(click)
activity.Invoke()

//Created argument for click & activity

Thanks :slightly_smiling_face:


#6

HI,

Please find the tutorial,

Thanks,
Karthik