Error in Selenium tests triggered from batch script in TFS Build step - selenium-webdriver

Step 1. I have written selenium tests and bundled it into executable jar.
Step 2. When I execute this jar tests runs normally. Invokes New browser and execute all steps.
Step 3. I created bat file to execute this jar. In this case also test execution happens normally.
Step 4. TFS Build integration. (TFS 2015)
- I created new build definition in TFS
- Added build step "Batch Script"
- Entered path of bat file created in step 3 in build step
- When I Queue this build. bat file gets called and test execution starts. But It does not open new browser..console says Started IE driver...it starts driver internal to build agent. and execution fails on setting value in textbox.
Click to see TFS Build Cosole
I can't use Visual studio tests. Requirement is to selenium tests should be triggered from jar created on Step 1.

Make sure the build agent is running in interactive mode.

First you could try to RDP to the remote build server(the build agent located) and manually run the batch file to see if it works.
If it's also not work then the issue may related the IE browser on the server.
If it works then maybe the TFS build service account don't have enough permission to run the IE driver. Please make sure the build service account has local Admin permission on the build server.

Related

No selenium server jar found error while running protractor tests in Azure DevOps

I am trying to run protractor test on Azure DevOps pipeline and getting the following error. Notice that jar file path is pointing to my local drive even when the tests are being run from Azure DevOps server. Any idea what I need to do?
Same test works when running from local machine but fails on Azure. I have the selenium-server-standalone-3.141.59.jar in my project's node_modules folder. What I don't understand is that why is it looking at my local machine (C:\Automation) when I am running test from Azure.
[13:33:31] I/launcher - Running 1 instances of WebDriver
[13:33:31] E/local - Error code: 135
[13:33:31] E/local - Error message: No selenium server jar found at
C:\Automation\my_app\node_modules\protractor\node_modules\webdriver
manager\selenium\selenium-server-standalone-3.141.59.jar. Run 'webdriver-manager
update' to download binaries.
This issue may be caused by:
selenium-server-standalone-3.141.59.jar does not exist in your project's node_modules\protractor\node_modules\webdriver-manager\selenium location.
selenium-server-standalone exists with different version.
Try to add a command line task to Update webdriver.
Useful resources:
Error: No selenium server jar found at "Location"
https://medium.com/#ganeshsirsi/protractor-end-to-end-tests-configure-on-ci-cd-tfs-vsts-azure-devops-publish-html-results-9143846f579f
https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/javascript?view=azure-devops&tabs=code#end-to-end-browser-testing

Tosca and Jenkins

Does anybody work with Tosca and Jenkins?
I have problems to run my batch script from Jenkins. It does not open browser, but job is finished successfully. Batch script runs normally when I try to run in on Windows, without Jenkins.
Anybody has an experience using these two tools together?
In order to use Tosca CI with Jenkins you need to:
Configure your Jenkins build project
Add an additional build step (Execute Windows batch command)
Call ToscaCIClient.exe/ToscaCIClient.jar with parameters
e.g. "PathToTosca\ToscaCI\Client\ToscaCIClient.exe" -t junit -r PathToResults\result.xml
Further information can be found here: https://support.tricentis.com/community/article.do?number=KB0012411
The issue your facing is because your running Jenkins as windows service, in this case headless execution happens technically your script is executed for other user account.
Solution
Instead of installing Jenkins host it on Apache Tomcat server
Download Jenkins war file
Copy it inside webapps folder of Tomcat
Run startup.bat
Refer-
https://www.tutorialspoint.com/jenkins/jenkins_tomcat_setup.htm
I had faced the same issue.
I am guessing your slave machine running the test has jenkins services installed as services.
Uninstall the service. (.jenkins/jenkins-slave.exe uninstall)
Use the .jnlp or slave.jar to connect the machine as a slave.
Your test should run fine after that.
If it does just create a batch file to connect the machine as slave whenever it is logged in.
I tried that. But in any case, Jenkins does not open the browser, so Tests from Execution List and I do not know why.
We use Tosca 10.

Why Installer made with installshield hangs when deployed using ReleaseManagementBuild.exe?

I have a build definition in TFS that compile my code, then using a post build event, I create a Setup.exe file using Installshield.
Using Release Management I am able to deploy the installer to a machine and start the installation process using the tool RunCommandLine, I add the required parameters to the setup.exe so it will install the application silently (using an answer file to avoid user interaction). This process works smoothly!!!
I want to go far, so I tried to launch a release from a gated check-in....change the build template, install the release management client in the build agent, configure my build definition......I performed a small change in my code, then a check-in.....it compiles in the server, and start the release process: deploy the installer and start the installation process using the tool RunCommandLine, I add the required parameters to the setup.exe so it will install the application silently.....but I got a timeout so the release was rejected. I check the machine and found that the setup.exe was still running 0% CPU usage.....very strange.
Checking the build log I found that the command line used by msbuild to launch the release process is something like this:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Release Management\Client\bin\ReleaseManagementBuild.exe -tfs "http://tfs:8080/tfs/Mycollection" -tp "Project1" -bd "Mybuild" -bn "Mybuild_20150623_15.1.0.9" -ts "QA" -nologo
I ran it, and the behavior was the same: the installer got stuck...0% CPU Usage.....Release rejected by timeout.....
So...I open Release Management Client look for the recently created release, and click in the option "Retry failed deployment"....It works!!!! the installer install!!! it does not hangs!!!
I was able to reproduce this behavior several times:
Release launched from Release Management Console......Works
Release launched from ReleaseManagementBuild.exe .......Does not works (Setup.exe hangs)
Any suggestion??

Execution of CodedUI tests on Remote machine without using the TestAgent/Controller

I have few Ordered tests which I execute locally using the VSTEST.CONSOLE.EXE In a batch file. I want to launch this batch file from remote system on about 15 VMs. I have the desktop active on all the VMs and user under which these test cases need to be executed are also same as the user logged in. When I try to execute the batch file using the PSExec it throws an error and dosent launch the tests the error shown is as below
C:\TestRunningFolder>vstest.console.exe C:\BuildsFolder\BVTTests.orderedtest /Settings:C:\BuildsFolder\QuestCodedUI.testsettings /Logger:trx
Microsoft (R) Test Execution Command Line Tool Version 12.0.30723.0
Copyright (c) Microsoft Corporation. All rights reserved.
starting test execution, please wait...
Warning: Warning: Test Run deployment issue: The assembly or module 'UiaComWrapp
r' directly or indirectly referenced by the test container 'c:\BuildsFolder\questcodedui.dll' was not found.Error: Test host process
exited unexpectedly.
Error: Failed to queue test run 'testuser#RemoteMachine 2015-05-14 15:57:49':
Unable to start the agent process.
Please let me know how can I execute the CodedUI tests on remote machine without using the TestAgent/Controller. Is it possible Via WMI ?. Anyone tried and succeeded please let me know.
Update : I was able to get past this issue by copying the required files in the folder. Now I am trying to launch the CodedUI tests using the PSExec.exe on remote system. I have remote desktop active and when I try to launch the batch file using the command line and it just gives me a message as shown below. PSEXEC.EXE \RemoteMachinename -i "c\users\testuser\desktop\Runtests.bat" when I do that it returns with error code 1 and tests are not started yet. I tried searching for solution I couldn't find anything that is usefull.
For the above mentioned scenario, please copy all the dependency dll (eg : Microsoft.Visualstudio.Qualitytools.CodeduiTest etc.) to the folder where your build dll (projectname.dll) file is copied. Make sure that you are using correct version of vstest that supports the version of the VS you are using. For example, if your code is builded using VS 2015, you have to use vstest.console.exe that comes with Test Agent 2015/Test Agent 2013 Update 5. This trick worked for me. Please let me know whether this works for you. Regards.

Error when execute within a TFS build definition

When I tried to call command-line to get latest update for my TFS mapped folder
TF get /recursive
The call complete successfully from the run window of Windows 7.
However, when I put the call into a .bat file and run it via InvokeProcess within a build definition (guide to do that), it failed.
The message is as below.
Unable to determine the workspace. You may be able to correct this by
running 'tf workspaces /collection:TeamProjectCollectionUrl'
What happens? How can I get around with that?
The reason this is happening is because when you run the command locally, the folder you're downloading is mapped to a workspace. When you execute the command in your build, it's running under the build service account, which doesn't have a workspace mapped for the folder you're specifying.
You shouldn't need to use the tf get command as part of your build. When you configure your build, you can specify which folders should be mapped in the workspace on the "Source Settings" tab. The build process will handle making sure the contents of the folders you map in your workspace are present automatically.
The cause for my issue is that the build agent execute my .bat file under a different Windows account which is something like NTSERVICE; when I run it directly, my TFS login account was used (which was previously remembered in Windows 7 Credential Manager)
So the solution is to put in the login name and password as TF get /login:SomeTFSUsername,SomePassword (see more here)

Resources