Page 1 of 1

Adding C# code to handle file upload window

Posted: Thu Nov 17, 2016 1:49 pm
by pandiyarajk
I am working in Ranorex Studio 6.0.1 and have recorded a web browser automation test for file upload. During the run, upload button was not clicked on first attempt. I am planning to write C# code to ensure whether it is clicked or not. If it was not clicked, I want to click the button again. But the .cs file for the recording is locked and I don't know how to handle this using user code.

I am new to user code actions. Please help me to add user code for the same.

Regards,
Pandi

Re: Adding C# code to handle file upload window

Posted: Fri Nov 18, 2016 8:34 am
by odklizec
Hi,

I would recommend you to read this User Guide chapter about creating User Code actions:
http://www.ranorex.com/support/user-gui ... tions.html

Basically, you need to create new user code action at a place, where you want to solve your problem. Anyway, instead of creating a workaround for failed click, you should investigate the reason why the click fails ;)

Re: Adding C# code to handle file upload window

Posted: Fri Nov 18, 2016 3:01 pm
by krstcs
Yeah, I agree with Pavel. The issue here is that your click isn't working the way you expected it to. That won't change just because you move the action to user code.

It is most likely a timing issue. Try to add a Delay action right before the click and see if that fixes it. If it does, then we know for sure it's timing. You can then work on making the xpath better or adding a WaitForExist action in place of the Delay (try not to use too many delays in your tests as they are not 'smart' and just wait the given time, while WaitFor(Exist/NotExist) are smarter and better for long-term test maintenance).