Can't find element using normalize-space(text()) - xpath

I'm having problems finding the following element with this xpath //label[normalize-space(text())='F. nacimiento:']
HTML DOM
The green element is the one I want to locate using the previous expression. I was able to find the red element with //label[normalize-space(text())='Servicio Decesos:'] and any other element of the same type.
I tried using //label[text()=' F. nacimiento:'] and works fine, but I'm using a loop and a the pattern //label[normalize-space(text())=' + foobar + '] to identify the rest of element.
My guess is something in that text string has a different char code to a whitespace or something like that, but I have no clue how to check that.
Is there a way to know what normalize-space is returning, in order to use it to id the element?
I have a different pattern to id the elements, but I'm pretty stubborn and this is a good chance to learn something new that could come handy in the future to solve similar issues.
I downloaded the html code as requested:
Here is the red fragment
<div class="sis-frame-bg">
<table class="wideBox" align="center" cellpadding="2" cellspacing="0">
<tbody>
<tr>
<th width="20%" align="right">
<label for="DTRIES_CODZONA">
<span class="sis-important">*</span> Código postal:</label>
</th>
<td><input name="nombdato_CODZONA_1" type="text" id="DTRIES_CODZONA" size="8" maxlength="8" onblur="seccionDecesos();" value="" data-regexp="_codigoPostal" autocomplete="off"></td>
</tr>
<tr>
<th width="20%" align="right">
<label for="DTRIES_SERVICOD">
<span class="sis-important">*</span> Servicio decesos:</label>
</th>
<td>
<select name="nombdato_SERVICOD_1" id="DTRIES_SERVICOD" onchange="seccionDescricionServicio();" data-name="Servicio decesos" data-obligatorio="true" data-regexp="_cadena">
<option selected="selected" value="" title="Elegir"> Elegir</option>
</select>
</td>
</tr>
<tr>
<th colspan="2" align="left">
<div id="datosServicioDecesos">
<!-- ASI261 -->
<!-- ASI261 -->
</div>
</th>
</tr>
</tbody>
</table>
</div>
And the green fragment
<table class="wideBox" cellspacing="0" cellpadding="2" align="center">
<tbody>
<tr>
<th align="right">
<label for="ASEG_FECHNACI">
<span class="sis-important">*</span> F. nacimiento:</label>
</th>
<td>
<input id="ASEG_FECHNACI" name="fechnaci" type="text" maxlength="10" size="12" class="js-popUpCalendar js-dateformat hasDatepicker" onblur="formatoFecha(this);" data-name="FECHA DE NACIMIENTO ASEGURADO" data-obligatorio="true" title="" value="" data-regexp="_fecha" autocomplete="off">
<img class="ui-datepicker-trigger" src="./ico_calendar.png" alt="..." title="...">
</td>
</tr>
</tbody>
</table>

You can use the below xpath.
//label[normalize-space(.)='* F. nacimiento:']
Screenshot

Related

float field value displaying as 0.0 always in spring boot

I am new to spring boot and I created a form using thymeleaf. There I have a float value field and that is always displaying 0.0 like a placeholder. I don't want to display a value for that. How can I solve this issue?
<form action="#" th:action="#{/save}" th:object="${product}" method="post">
<table border="0" cellpadding="10">
<tr>
<td>Product Name:</td>
<td><input type="text" id="name" th:field="*{name}"/></td>
<td class="error" th:errors="*{name}"></td>
</tr>
<tr>
<td>Brand:</td>
<td><input type="text" th:field="*{brand}"/></td>
<td class="error" th:errors="*{brand}"></td>
</tr>
<tr>
<td>Made In:</td>
<td><input type="text" th:field="*{madein}"/></td>
<td class="error" th:errors="*{madein}"></td>
</tr>
<tr>
<td>Price:</td>
<td><input type="text" th:field="*{price}" th:placeholder="price"/></td>
<td class="error" th:errors="*{price}"></td>
</tr>
<tr>
<td colspan="2">
<button type="submit">Save</button>
</td>
</tr>
</table>
</form>
Here last field price having the issue.
click here for the image
You should use a capital F Float for your property rather than a float. It has 2 states:
A null default won't display anything in the form fields.
After the form has been submitted, the field will have the correct value (and will display as a number).

xpath: Unable to locate Select dropdown

I am getting the following exceptions,
invalid selector: Unable to locate an element with the xpath
expression //select[#name='countryList because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string
'//select[#name='countryList' is not a valid XPath expression.
Here is my html code,
<form method="post" action="/eClaims/app" name="itemEditForm" id="itemEditForm" class="itemEditForm" accept-charset="utf-8">
<div style="display:none;"><input type="hidden" name="formids" value="TextField,wdd">
<input type="hidden" name="component" value="ClaimItemDetail.itemEditForm">
<input type="hidden" name="page" value="ClaimItemPage">
<input type="hidden" name="service" value="direct">
<input type="hidden" name="session" value="T">
<input type="hidden" name="If_87" value="T">
<input type="hidden" name="For_3" value="ecfqwcqw">
</div>
<input type="text" name="TextField" value="" id="requestKeyItemId" style="visibility: hidden">
<!-- START ORDERED Item detail table -->
<div name="mainClaimItemDetailDiv">
<table width="100%" bgcolor="#cccccc">
</table>
<!-- show item information section START -->
<table width="100%" bgcolor="#cccccc">
<tbody><tr bgcolor="silver">
<th>
HP Item Ref.
</th>
<th>
Estimated Value
(
AUD
)<br>
</th>
<th>
Country of Origin
</th>
<th>
Serial #
</th>
<th>
Estimated Value($)
</th>
<th>
<input type="text" name="clmid" value="" id="clmid" style="visibility: hidden;">
</th>
</tr>
<tr width="100%" bgcolor="#cccccc">
<td align="center">
56730270
</td>
<td>
252.79
</td>
<td align="center">
<!--<span jwcid="countryList_1" onchange="javascript:checkIfDropdownValueNull(this);" ></span> -->
<select name="countryList_1" id="countryList_1" style="width:50px;">
<option value="">--please select--</option>
<option value="AF">AF</option>
<option value="ZW">ZW</option>
</select>
</td>
<td align="center">
<input type="text" name="serialNo_2" value="5CD6340S04" id="serialNo_2" maxl="10" onfocus="javascript:onProductFocus(this);" size="10" onblur="javascript:onItemDataChange(this,10)">
</td>
<td align="center">
187.06
</td>
<td align="center">
<input type="submit" name="Submit" id="fetchitemBtn" class="fetchitemBtn" style="visibility: hidden;">
</td>
</tr>
</tbody></table>
</form>
So far i have used the following locators,
//select[contains(#id,'countryList_1')]
//select[#id,'countryList_1']
//**[#id="itemEditForm"]/div[#name='mainClaimItemDetailDiv']/table[2]/tbody/tr[2]/td[11]
//**[#id="itemEditForm"]/div[#name='mainClaimItemDetailDiv']/following::select[#id='countryList_1']
Although, the last xpath is not locating any element.
I have used many more but to no avail.
please help.
Thanks in advance
Use following xpath in your code it is working fine
You can follow any of these xpaths:
//select[#id='countryList_1']
//select[#name='countryList_1']
//select[#id='countryList_1'][#name='countryList_1']
//select[contains(#name,'countryList_1')]
In your error log
"The string '//select[#name='countryList' is not a valid XPath
expression."
that means your xpath is not correct, you have some syntax error in xpath
your xpath is missing an ']'. use correct xpath as shown below
//select[#name='countryList']

HTML TR and TD alignment

This is what I've done, but I failed to make the alignment same as next picture. Hope someone can help.
<tr>
<td > </td>
<td ><b>Type Description</b></td>
<td align="Center"><b>:</b></td>
<td colspan="3"><input name="txtCAEMGE" value="<%=server.HTMLEncode(StrCAEMDE)%>" type="text" class="NormalInputTextField" size="30" >
<input name="chkHR" type="checkbox"> Tick for disable update from HR system
</td>
</tr>
<tr>
<td > </td>
<td > </td>
<td colspan="3">
<input name="chkHR2" type="checkbox"> Tick for disable update from HR system
</td>
</tr>
I would experiment with putting both checkboxes inside a single container (e.g. a DIV). If you want to position them as a single entity then it will be easier if they are organised in the DOM this way.
e.g.
<body>
<table>
<tr>
<td><b>Type Description</b></td>
<td align="Center"><b>:</b></td>
<td>
<input type="text" value="test value" size="30" >
<div style="display: inline-block;">
<div style="display: block;"><input name="chkHR" type="checkbox"> Tick for disable update from HR system</div>
<div style="display: block;"><input name="chkHR2" type="checkbox"> Tick for disable update from HR system</div>
</div>
</td>
</tr>
</table>
</body>

How to display the similar information in every view?

I would like to display the information about user's registration state. It should be displayed on every view, but i consider, that writting this code for about 20 times is a bad idea. By the way, this is the code, it works, i guarantee that:
View/RegistrationInfo:
<table width="95%" border="0" cols="2">
<tr>
<td width="50%" height="124"><h2><strong>Simple Blog </strong></h2></td>
<td width="50%" height="124">
#if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
{
using (Html.BeginForm("LogOff", "Account"))
{
<table width="95%" height="86" border="0">
<tr>
<td width="50%" valign="middle">Hello, #System.Web.HttpContext.Current.User.Identity.Name</td>
<td width="50%" valign="middle" align = "right"><input type="submit" value="Exit" /></td>
</tr>
</table>
}
}
else
{
using (Html.BeginForm("LogIn", "Home"))
{
<table width="95%" height="86" border="0">
<tr>
<td width="45%" valign="bottom">Login:</td>
<td width="45%" valign="bottom">Password:</td>
<td width="10%"></td>
</tr>
<tr>
<td width="45%">
<p>
<input type="text" name="login" />
</p>
</td>
<td width="45%">
<p>
<input type="password" name="password" />
</p>
</td>
<td width="10%" align="left">
<input type="submit" value="Enter" />
</td>
</tr>
<tr>
<td width="45%" valign="top">
#Html.ActionLink("Register", "Register", "Account")
</td>
</tr>
</table>
}
}
</td>
</tr>
</table>
<hr align="left" width="100%" size="2" />
As you can see, this view doesn't require to be strongly typed... and i don't know, should I modify any controllers (because, all information is stored in HTML Context), and how. I tried to call
#Html.RenderAction("RegistrationInfo", "Home");
or
#Html.RenderPartial("RegistrationInfo", "Home");
and every time i receive compile error with message about invalid parametres
While Darin's answer perfectly covers your question, I would point out that registration information seems like it's part of your layout more (master page for the .aspx-inclined) than an actual action.
So what I would do (and indeed, do do) is put it either in the header part of your layout in the top right or under your side menu or something, and let the layout handle all the details of rendering it (with a conditional around it to hide it when you're not logged in, so you don't see it on the login screen).
The following should work:
#Html.Partial("~/Views/Home/RegistrationInfo.cshtml")
Or if you are inside a view of the Home controller simply:
#Html.Partial("RegistrationInfo")
Or if you put this partial in ~/Views/Shared/RegistrationInfo.cshtml you will be able to reference with the shorthand syntax.

Coldfusion forms and image upload with cffile

I'm learning some Coldfusion, and I'm having trouble with this small form based application I'm building for a coworker.
Here is the first page: http://pastebin.com/aLPYHPsF
As you can see, what I want to do is get the user input and take that input and output it to html. The text stuff works fine, but I can't get the image to upload! What I want to do is have the user click upload, get a confirmation, then click submit and they are sent to the generated html (cfm) page. On the page is a resized version of the image they uploaded.
Please tell me what I'm doing wrong! Right now when "upload" is clicked, the form just dumps.
It's because of you forgot to assign enctype="multipart/form-data" to your first cfform. I've edited some of your coding. Check it out.
<cfset strPath = ExpandPath( "./" ) />
<cfset strPath = GetDirectoryFromPath(GetCurrentTemplatePath()) />
<table width="100%">
<tr>
<td align="center">
<cfform name="ecaform" action="ecagenerator.cfm" enctype="multipart/form-data">
<table style="font-family: arial; font-size: 9pt">
<tr><td height="30px" align="center" colspan="2" style="background-color: #020058; color: #FFFFFF; font-family: arial;">
<b>ECA Newsletter Creation Form</b>
</td>
</tr>
<tr><td height="20"></td></tr>
<tr>
<td>Earned from:</td>
<td>
<cfinput
type="radio"
name="earnedfrom"
value="UC">
UC
<cfinput
type="radio"
name="earnedfrom"
value="ECA">
ECA
</td>
</tr>
<tr>
<td>First Name:</td>
<td>
<cfinput
name="firstname">
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<cfinput
name="lastname">
</td>
</tr>
<tr>
<td>Instructor's Name:</td>
<td>
<cfinput
name="instructorname">
</td>
</tr>
<tr>
<td>Date (MM/DD/YYYY):</td>
<td>
<cfinput
name="date">
</td>
</tr>
<tr>
<td>Sex:</td>
<td>
<cfinput
type="radio"
name="sex"
value="male">
Male
<cfinput
type="radio"
name="sex"
value="female">
Female
</td>
</tr>
<tr>
<td>Certificate Type:</td>
<td>
<cfinput
type="radio"
name="certtype"
value="Private">
Private
<cfinput
type="radio"
name="certtype"
value="Recreational">
Recreational
<cfinput
type="radio"
name="certtype"
value="Commercial">
Commercial
</td>
</tr>
</table>
<table style="font-family: arial; font-size: 9pt; margin-top: 20 px;">
<tr>
<td>
Upload the photo:
</td>
</tr>
<tr>
<td>
<cfif isDefined("form.fileUpload")>
<cffile action="upload"
fileField="fileUpload"
destination="#strPath#"
accept="image/*">
<cfimage action="resize"
width="200"
height="200"
source="#strPath##file.serverfile#"
destination="#strPath##file.serverfile#"
overwrite="yes">
<img src="<cfoutput>#file.serverfile#</cfoutput>">
</cfif>
</td>
</tr>
<tr>
<td>
<form enctype="multipart/form-data"
method="post">
<input type="file"
name="fileUpload" /><br /><br />
<input type="submit"
value="Submit"
action="ecagenerator.cfm" />
</form>
</td>
</tr>
</table>
<table style="margin-top: 20px;">
<tr>
<td>
<cfinput
type="submit"
name="Submit"
value="Submit">
</td>
</tr>
</table>
</cfform>
</td>
</tr>
</table>
You might want to look into using <cfdiv> for the image upload section. Basically you want the form for image uploading be inside the <cfdiv>, so that the form is submitted through ajax. Have the image form action post to a previewImage.cfm that uses <cffileupload>, validate with isImageFile() if it is an image file, then use <cfimage> to resize it and display a thumbnail (may use action="writetobrowser"). The easiest way to associate the uploaded image with the parent form would be storing the file path in Session I guess, if you don't want to code up extra Javascript.

Resources