How to use The "click" with a button that load after some delay?


#1

Yasser Thlijani
October 03, 2016 13:52 NONE
Hello,

I want that the “click” activity start when the button appear (Excel macro).

For example If I want to click on a button that appear after a delay. How can we program the click activity so it execute when the button appear. The delay is not constant. Depending on the performance of the computer the delay may change.

To be more specific, I open an excel that contain macros. I used buttons to execute the macros. I want to use the “click” activity to click on buttons. The problem is that the excel file load after a delay. And it’s variable depending on the computer performance.

Thanks for your help.

Yasser


#2

Corneliu Niculite October 03, 2016 15:30 Official comment
Hello Yasser,

You already have an activity called Execute Macro. You provide the name of that Macro and it will be run, so you don’t have to do UI automation to trigger the macro… Just make sure to include it in an Excel application scope so that you have the file open before.

Now if you have message boxes during the execution of the macro, they will not be seen because the Execute macro activity does not really end before you click the button. Therefore, you need to put the Execute macro activity in Parallel with the Click activity. So you will have a Parallel box and two branches, one with Execute macro and one with the Click. The parallel box will only finish when both activities finish.

Let me know if this helps.

Corneliu


#3

Yasser Thlijani October 03, 2016 16:42
Corneliu,

Thanks for your answer. But the "execute Macro will need to run after the excel file is fully open no? The problem I have here is that the excel file I’m using take up to 20 seconds to open. So I need to program something that will recognize that the excel file is fully loaded.

Also I’m using another software used in our production line to communicate with our produced units. This also will have delays at different stages (communication speed between PC and produced unit). This is also causing me problems as the delays are variable. The only way I found is to add a “delay” before any “click” and in the delay time I put the worse case scenario.

Thanks again for your help.

Yasser


#4

Corneliu Niculite October 03, 2016 18:00
Hello Yasser,

The Excel application scope should usually wait until fully open to start the next activity. Let me know if this is not happening.

Regarding the timing issue, this is a different discussion and should be treated separately in more detail. Please open a new topic in the forum to help other people with an easier follow-up.

Quick answer: use the TimeoutMS property at your advantage. If the element is found in the Timeout, the action is executed, if not it throws and error. Therefore, increasing the Timeout to more than 30 seconds will give you the desired behavior.

Best regards,

Corneliu


#5

Yasser Thlijani October 06, 2016 10:38
Thanks Corneliu. I like the timeout idea. I will try that.

Yasser