Selenium test case requires an if/else condition. How can I insert an if/else condition in a Selenium test case? We have a build file which has a variable CUSTOMNAME which is passed at runtime through an Ant command. If the value is passed, then execute the below line else ignore and move on with rest of the test case.
Run Keyword If || ${CUSTOMNAME}>0 || Select Checkbox
Build file:
<target name="Compute" depends="init">
<echo message="${TODAY_DE}"/>
<exec executable="cmd">
<arg line="/k start cmd.exe"/>
<arg line="/k pybot"/>
<arg line="--variable BROWSER:${Internet}"/>
<arg line="--variable REMOTE_URL:${Remote_Url}"/>
<arg line="--variable SERVICE:${Service}"/>
<arg line="--variable CUSTOMNAME:${CUSTOMNAME}"/>
<arg line="--name ${Service}_${Internet}"/>
<arg line="--doc ${Service}_${Internet}"/>
<arg line="-o ${output.dir}\${Service}_${Internet}_output.xml"/>
<arg line="-l ${logs.dir}\${Service}_${Internet}_logs.xml"/>
<arg line="-r ${docs.dir}\${Service}_${Internet}.html"/>
<arg line="${Compute_Test}"/>
</exec>
</target>
You can use the if attribute to run the Compute <target> only if the CUSTOMNAME property is set:
<target name="Compute" depends="init" if="CUSTOMNAME">
Notice the added if="CUSTOMNAME".
Related
I have a Liquibase changeset that executes a PostGIS executable command in order to convert a shapefile (GIS file) to a table.
<!-- Will execute :
export PGPASSWORD=postgres
shp2pgsql
-s 4326 -I /data/comptes-france/territoire/2016/communes.shp
public.communes_2016 | psql -d comptesfrance -U postgres -h localhost
-->
<changeSet id="shp2pgsql_communes_2016" author="mlebihan" failOnError="false">
<comment>Importation des shapefiles des contours des communes 2016</comment>
<executeCommand executable="export">
<arg value="PGPASSWORD=postgres"/>
</executeCommand>
<executeCommand executable="shp2pgsql">
<arg value="-s"/>
<arg value="4326"/>
<arg value="-I"/>
<arg value="/data/comptes-france/territoire/2016/communes.shp
public.communes_2016"/>
<arg value="|"/>
<arg value="psql"/>
<arg value="-d"/>
<arg value="comptesfrance"/>
<arg value="-U"/>
<arg value="postgres"/>
<arg value="-h"/>
<arg value="localhost"/>
</executeCommand>
</changeSet>
As you read, it's plenty of mentions of 2016 year.
In its <comment>.
in data/comptes-france/territoire/2016/communes.shp public.communes_2016, where it appears two times.
Is there a way to declare a local variable in a changeset, so that I can use a $year or something else, to avoid repeating 2016 everywhere?
This variable has to be only local to that changeset, because next changeset will be willing to do the same, but for 2017 and so on, (and maybe, in a later question, I will ask you about the ability to perform a for loop, if this question receives a positive answer).
Upon trying to use the MKS task for apache ant, I need to specify the application executing the command. In the documentation I found, it says for example "si" or "im". I'm a little confused at this considered ant is used from command prompt so I'm not sure which application would be doing said command, nor do I know what applications "si" or "im" might be. I am using this task to try and send and receive build info to Integrity if that is pertinent. I was able to find this CLI reference guide for Integrity (link at bottom) which only uses im as a prefix, so I'm thinking that's the one I want to use, but I would appreciate an explanation as to what application im indicates (possible Integrity -something) and what one would specify with "si". Thanks
https://bugs.eclipse.org/bugs/attachment.cgi?id=52225
The si commands are used for Source Integrity tasks (the SCCM side of things), while the im commands are used for Integrity Manager commands (the workflow and document management side of things).
The Integrity client should have man page support on all platforms, so you should be able to run man im or man si to see a breakdown of all the supported commands.
In addition, with newer releases of the client, pressing F1 should get you a help interface, which includes documentation on CLI commands.
The guide to the link you posted is a very old version of the product CLI reference, and only for the im commands.
Since you're talking about using Ant, I'm assuming you're trying to perform builds, which will mostly involve si commands (creating sandboxes, checking out members, etc.).
Here are a couple examples of using si in ant:
<target name="check.mks.conn">
<echo message="Checking if an MKS connection exists. If not, one will be created." />
<exec executable="si" failonerror="true">
<arg line="connect" />
<arg line="--hostname=${mks.server}" />
<arg line="--port=${mks.port}" />
<arg line="--user=${mks.user}" />
<arg line="--gui" />
</exec>
</target>
<!-- =================================================================== -->
<!-- If the sandbox already exists, resync the files -->
<!-- Manually drop any empty folders as resync does not do this. -->
<!-- =================================================================== -->
<target name="resync.sandbox" unless="clean.build">
<exec executable="si" failonerror="true">
<arg line="resync" />
<arg line="--hostname=${mks.server}" />
<arg line="--port=${mks.port}" />
<arg line="-R" />
<arg line="-f" />
<arg line="-Y" />
<arg line="-S ${basedir}\${prj.name}\project.pj" />
</exec>
<delete includeemptydirs="true">
<fileset dir="${prj.name}" excludes="**\*.*" />
</delete>
</target>
<!-- =================================================================== -->
<!-- Drop and recreate the sandbox. -->
<!-- =================================================================== -->
<target name="create.sandbox" if="clean.build" >
<exec executable="si">
<arg line="dropsandbox" />
<arg line="--hostname=${mks.server}" />
<arg line="--port=${mks.port}" />
<arg line="--noconfirm" />
<arg line="--batch" />
<arg line='--delete=none' />
<arg line="-Y" />
<arg line="${basedir}\${prj.name}\project.pj" />
</exec>
<delete dir="${prj.name}" />
<exec executable="si" resultproperty="createSBResult">
<arg line="createsandbox" />
<arg line="--hostname=${mks.server}" />
<arg line="--port=${mks.port}" />
<arg line="--project=c:/Projects/StoreWeb2/${prj.name}/project.pj" />
<arg line="--projectRevision=${checkpoint.version}" />
<arg line="--populate" />
<arg line="--recurse" />
<arg line="-Y" />
<arg line="${basedir}\${prj.name}" />
</exec>
<!-- Check if the project is empty but for the mks system file project.pj -->
<pathconvert property="is.project.not.empty" setonempty="false">
<fileset dir="${prj.name}">
<exclude name="project.pj"/>
</fileset>
</pathconvert>
<condition property="try.mainline.storeweb">
<not>
<and>
<equals arg1="0" arg2="${createSBResult}"/>
<isset property="is.project.not.empty" />
</and>
</not>
</condition>
<antcall target="create.sandbox.mainline">
<param name="prj.name" value="${prj.name}"/>
</antcall>
</target>
I have a .bat file to start selenium grid and I want it to stay open. I read the documentation on the ANT page but tried couple things but cant figure it out. This is what i have so far. It says it executed it but i cant tell.
<project>
<target name="runBatch">
<exec executable="cmd" fork="true" spawn="true">
<arg value="startGRID.bat"/>
</exec>
</target>
</project>
This is what startGRID.bat looks like when i run from command prompt.
so i got it to start but now i need it to start in another prompt.
<project>
<target name="startGRID">
<exec dir="." executable="cmd">
<arg value="/c"/>
<arg value="java -jar selenium-server-standalone-2.43.1.jar -role hub"/>
</exec>
</target>
</project>
I got error
BUILD FAILED
C:\Projects...\build.xml:987: com.microsoft.sqlserver.jdbc.SQLServerException: The procedure 'sys.sp_addlogin' cannot be executed within a transaction.
How can i make an ant sql task run this?
thanks
Try use CREATE LOGIN instead of sp_addlogin
http://msdn.microsoft.com/en-us/library/ms189751.aspx
Well that I tried too but since I couldn't change the SQL script I found a walk around by using executable
<exec executable="sqlcmd" >
<arg value= "-S"/>
<arg value= "${ServerName}"/>
<arg value="-d"/>
<arg value="DataBaseName"/>
<arg value="-i"/>
<arg value="${build.sql}/mssql/script.sql"/>
<arg value="-E"/>
<arg value="-b"/>
</exec>
It looks like there are (at least) two options for getting nant to use csproj files: using the task of NAntContrib or using msbuild.exe directly (e.g., codecampserver). Am I reading this right, and if so, what is the advantage of using msbuild.exe over the NAntContrib task?
The NAntContrib assumes .NET Framework V2.0. If you want to use .NET 3.5, you'll need to call MsBuild.exe directly. As you upgrade to new versions of .NET, you need only modify the MSBuildPath property.
Here's an example:
<property name="MSBuildPath" value="C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe"/>
<target name="build">
<exec program="${MSBuildPath}">
<arg line='"${SolutionFile}"' />
<arg line="/property:Configuration=${SolutionConfiguration}" />
<arg value="/target:Rebuild" />
<arg value="/verbosity:normal" />
<arg value="/nologo" />
<arg line='/logger:"C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll"'/>
</exec>
</target>
The value MSBuildPath for different versions of .NET are
2.0, 3.0 C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe
3.5 C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe
4, 4.5.x, 4.6.x, 4.7.x C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
For a 32-bit build, change Framework64 to Framework
Update
Following up on some of the comments, the value attribute is used for parameters that have no white space characters where as line is used for parameters that contain white spaces. Otherwise, the NAnt would use the space as an end of input.
Here is a simple target
<target>
<loadtasks assembly="${nant::get-base-directory()}/../../nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll" />
<msbuild project="${filepath.root}/yourproject.csproj" verbose="true">
<arg value="/p:Platform=${build.platform}" />
<arg value="/t:Rebuild" />
<arg value="/p:OutputPath=${build.dir}/bin/" />
</msbuild>
</target>