Page 1 of 1

UI tests fail when run from TeamCity

Posted: Mon Apr 30, 2018 9:47 am
by simmisj
Hi.
I have some test cases that do not use any UI and then a few that do use UI. When I run the tests from the machine, either through ranorex studio or simply double clicking the .exe that is generated, then everything runs fine. Then when I use TeamCity to build the code from BitBucket, deploy it to the test machine, and eventually run the .exe file then the UI tests fail with a message saying that the UI element was not found.

Is there some limitation when using TeamCity to run UI tests?

Re: UI tests fail when run from TeamCity

Posted: Mon Apr 30, 2018 10:25 am
by odklizec
Hi,

Are you sure the test exe is started with enough privileges (administrator)?
Are you sure the TeamCity agent is started as standard windows user and not as service? In case you see black screenshots in report in report, exe is not started as standard windows user.
Have you tried to start (manually) the exe file deployed by TeamCity?
Also, make sure the Ranorex settings are the same on both local and team city VM! Different settings are most common cause of different results ;)

Re: UI tests fail when run from TeamCity

Posted: Mon Apr 30, 2018 11:15 am
by simmisj
I have successfully manually started the .exe file and that works fine.
The screenshots are just blank so maybe the issue is with the agent being started as a service. I will change that and see if that fixes it.

Re: UI tests fail when run from TeamCity

Posted: Mon Apr 30, 2018 11:50 am
by simmisj
I have changed the service to use an elevated user account but it still just shows blank screenshots and fails with this error: "Failed to find item 'KeyingClientAutoTestsRepository.AuthenticationForm.Username'.
No element found for path '/form[@controlname='AuthenticationForm']/container[@controlname='_groupLogin']//text[@accessiblename='Username:']' within 1m. "

Re: UI tests fail when run from TeamCity

Posted: Mon Apr 30, 2018 12:04 pm
by odklizec
Hi,

Blank screenshot means, that the test has no access to UI. In other words, the TeamCity agent is most probably still running as a service. Are you sure you followed the steps for Team City Build agent?...
https://www.ranorex.com/blog/integratin ... ess/#agent

Re: UI tests fail when run from TeamCity

Posted: Mon Apr 30, 2018 2:03 pm
by simmisj
Yeah. I do exactly like it says on that webpage.
I run it in administrator mode and start it myself using "agent start" but still it has the screenshots blank.

Also. When I am logged in myself and run the tests from TeamCity then it works pretty well. I simply keep the session open and do nothing.
But if I log out of the auto test server and run the tests from TeamCity then it fails with an error indicating "Failed to find item 'KeyingClientAutoTestsRepository.KeyingForm.Tabs.Text'.
No element found for path 'tabpagelist[@controlname='tabs']/tabpage[@controlname='keyingPageTab']/container[@controlname='mainPanel']/element[@controlname='ControlStack']/?/?/element[@controlname='ControlStack']//text[@accessiblerole='Text']' within 1m. "

Re: UI tests fail when run from TeamCity

Posted: Mon Apr 30, 2018 2:08 pm
by odklizec
Ah yes, you must keep the session open! Ranorex cannot work with closed session. Closing or even minimizing remote desktop kills the session. Check for example this post, with some suggestions how to keep the session open... https://www.ranorex.com/forum/ranorex-s ... tml#p40652

Re: UI tests fail when run from TeamCity

Posted: Tue May 01, 2018 10:17 am
by simmisj
Absolutely right.
I managed to use tscon.exe to achive what I wanted.
Thanks.