selenium tests aplication path problem test not run on selected url - command-line

I try to start my selenium test using command line but test are fired to http://mycomputer and not to http://mycomputer/myapplication
D:\projectsnet\Production\MyWebTests\tools\selenium-server>java -jar selenium-
server.jar -Dhttp.proxyHost=mycomputer -Dhttp.proxyport=4444 -htmlSuite "*firefox" "ht
tp://mycomputer/myapplication/" "D:\mypathtotestssuites\0001-testsuite.html" "c:\temp\result.html"
In test cases I have got link
<link rel="selenium.base" href="http://mycomputer/myapplication/" />

This is by design.
If you are doing development against http://mycomputer/myapplication/ then I would recommend that you do http://mycomputer as your baseURL and then add
open | /myapplication/
To the top of your tests.

Related

How do I have a meaningful error message from powershell script running in TeamCity build?

I have a TeamCity build and one of the steps is an MSBuild invokation of a .proj file:
Runner type: MSBuild
Build file path: TestProject.proj
Targets: Test
inside the .proj I have targets:
<Target Name="DeployTestService">
<Message Text="Deploying test service" />
<Exec Command="powershell -Command "& { myUsefulPsScript.ps }"" />
</Target>
<Target Name="Test">
// other stuff, then
<CallTarget Targets="DeployTestService" />
</Target>
and it works good most of the time. Yet if the powershell script fails (an unhandled exception is thrown and I can see its text in the full log) and exits with non-zero code I see the following in Teamcity build results:
Tests passed: (some number); exit code 1
and the build tree just says:
Build failure condition (1)
Process exited with code 1
[Time]Process exited with code 1
and until I get the full log I don't really know which step failed and how exactly. It's not about fixing the initial problem it's about locating the faulty step faster.
Is there a way to make Teamcity say something like "runner in step N failed with this error message [message which I see in the full log]"?
You need to use the Teamcity output format. For example, every time a new test starts, print:
##teamcity[testStarted name='foo|'s test']
This way Teamcity will know what was the last step or the last test before the app crashed and it will be able to format the output accordingly.

' ReferenceError: browser is not defined ' while running cucumber-js in protractor-cucumber

I am using protractor 5.2.2. and cucumber 3.2.0.I am getting an error "browser is not defined" when i am run cucumber-js.
Feature: Login page test
Scenario: Verify whether the user is able to navigating to the login page
When I go to "https://in.linkedin.com/"
and my step code is
var {defineSupportCode} = require('cucumber');
defineSupportCode(function ({ setDefaultTimeout, Given, When, Then }) {
setDefaultTimeout(60 * 1000);
When(/^I go to "(.*)"$/, function (url, callback) {
browser.get(url).then(callback);
});
)};
It looks like cucumber is not catching the global browser variable.
To run protractor script, you need to use command like protractor conf.js no matter which test framework(jasmine, cucumber) you used.
When use cmd protractor to start running, it will load browser into Nodejs runtime's global variable.
After protractor complete load browser into global, the package protractor-cucumber-framework will generate and execute another command line which will use cucumber-js to run cucumber feature files, but now in the Nodejs runtime, global variable has browser this property and its value is not null/undefined.
That's why we have to need more two packages: cucumber and protractor-cucumber-framework

msdeploy via powershell and psake fails

So I'm trying to use powershell and psake for my build and deployment. I've tried without any success to call the following psake task.
Exec { msdeploy.exe "-verb:sync"
"-source:package="D:\path-to-package\zip-file-name.zip"
"-dest:auto,computername=http://my-server-name-here:8090/MsDeployAgentService2/" -setparam:Name="IIS Web Application Name,Value=iis-web-app-name-here" "-allowUntrusted" }
So in an effort to get things moving I removed the offending setparam:Name="IIS Web Application Name,Value=iis-web-app-name-here". It worked but took the IIS Web Application Name parameter from the ..SetParameters.xml as expected.
<setParameter name="IIS Web Application Name" value="Default Web Site/project.name_deploy" />
There's clearly something wrong with the syntax of setparam:Name="IIS Web Application Name,Value=iis-web-app-name-here" but I've tried a dozen (or more) variations including
-setparam:"IIS Web Application Name=iis-web-app-name-here" > omitting the name,value
-setparam:"IIS` Web` Application` Name=iis-web-app-name-here" > using back ticks
I really can't work out what I'm doing wrong and may have to resort back to using an msbuild file to get things moving.
The error I receive is : > all arguments must begin with -
I believe you need to quote the parameters as follows:
setparam:Name="IIS Web Application Name",Value="iis-web-app-name-here"
Note the additional quotes before the comma and after the equals sign following Value.

Why Msbuild task failed to deploy database, but Exec work fine

I'm trying to deploy database project ( dbproj format, not new SSDT sqlproj ) inside automated build server processing. I found the following:
When I'm calling deploy with Exec task in my Msbuild script - everything working fine:
<Exec Command="$(MSBuildPath)\MSBuild.exe $(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj
/t:Deploy
/p:OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\
/p:TargetDatabase=$(DeployDatabaseName)
/p:TargetConnectionString=$(DeployDatabaseConnectionString)" />
But when I try to repeat this with Msbuild task - it behaves differently:
<MSBuild Projects="$(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj"
Targets="Deploy"
Properties="Configuration=$(BuildConfiguration);
TargetDatabase=$(DeployDatabaseName);
TargetConnectionString="$(DeployDatabaseConnectionString)";
OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\;
" />
Msbuild task broke on semicolons in DeployDatabaseConnectionString:
<DeployDatabaseConnectionString>Data Source=$(DeployDatabaseServer);Integrated Security=True;Pooling=False</DeployDatabaseConnectionString>
It will report something like this:
The name "Integrated Security" contains an invalid character " ".
But if I replace semicolons with percent encoding value - %3B - it will broke inside SqlDeployTask:
error MSB4018: The "SqlDeployTask" task failed unexpectedly.
What is the proper way to pass TargetConnectionString to Deploy target of SqlProject ?
PS: I Could live with exec task fine, but make a call to msbuild.exe inside msbuild script just hurts my inner perfectionist man.
I found the proper way - new Msbuild allow to define AdditionalProperties metadata on item. So with this feature everything work fine and have no problems with escaping\encoding
<ItemGroup>
<DbProjectToBuild Include="$(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj">
<AdditionalProperties>Configuration=$(BuildConfiguration)</AdditionalProperties>
<AdditionalProperties>OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\</AdditionalProperties>
<AdditionalProperties>TargetDatabase=$(DeployDatabaseName)</AdditionalProperties>
<AdditionalProperties>TargetConnectionString="Data Source=$(DeployDatabaseServer);Integrated Security=True;Pooling=False"</AdditionalProperties>
</DbProjectToBuild>
</ItemGroup>
<MSBuild Projects="%(DbProjectToBuild.Identity)" Targets="Build;Deploy" />

Running JUnit-Tests that uses SWT-Display fails on Jenkins

I a have a few JUnit-Tests that makes use of the current Display to instantiate a few controls (TreeViewer for instance). Locally that works fine, no problem. When I commit these tests and jenkins runs the test I get a failed test for each test that makes use of Display.
My unit test uses the display variable in this manner:
#Test
public void testUtils() {
Display display = Display.getCurrent();
Shell shell = new Shell(display, SWT.NONE);
// org.eclipse.swt.widgets.Composite composite = new
// org.eclipse.swt.widgets.Composite(
// shell, SWT.NONE);
TreeViewer viewer = new TreeViewer(shell, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL);
The error log jenkins generates is:
Time elapsed: 0.13 sec <<< ERROR!
org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
at org.eclipse.swt.SWT.error(SWT.java:4109)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:902)
at org.eclipse.swt.widgets.Display.create(Display.java:890)
at org.eclipse.swt.graphics.Device.<init>(Device.java:154)
at org.eclipse.swt.widgets.Display.<init>(Display.java:499)
at org.eclipse.swt.widgets.Display.<init>(Display.java:490)
at org.eclipse.swt.widgets.Display.getDefault(Display.java:1693)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:260)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:253)
at
Is there any thing wrong with the way I am using Display in my tests? It works when executed on my local machine
The way you use Display looks OK to me. The error is likely related to the fact that your server is not running Gnome, hence SWT can't create a Display when you ask it to.
UPDATE
I just found a recent blog post, which explains what you need to do to run SWT UI tests on a headless server in more detail. Although the steps provided are meant for Hudson, they should be applicable to Jenkins as well.
It should all boil down to these two steps:
Check Run Xvnc during build (and don’t bother to check take screenshot, it doesn’t work)
Add an Execute shell build action before launching your tests with metacity –replace –sm-disable &
See the linked blog post for screenshots and more details.
You can try following two things,
execute command "xhost" or "xhost+" from your terminnal.
execute command "xhost" or "xhost+" from, jenkins terminal.