I've got a tbody in my .jsp file:
<tbody>
<logic:iterate name="tableList" property="list" id="e">
<tr class="text-center">
<td class="text-center"><bean:write name="e" property="A" /></td>
<td class="text-center"><bean:write name="e" property="B" /></td>
<td class="text-center"><bean:write name="e" property="C" /></td>
</tr>
</logic:iterate>
</tbody>
I want to iterate my property "A" only once, but "B" and "C" iterate normally.
Is any way to do that?
I tried verify it in java class, and when my A property has only one item I used rowspan, but when I wanted to:
<td rowspan="12" class="text-center"><bean:write name="e" property="A" /></td>
it can't work too (whole table is destroyed).
You can use a counter on the indexId attribute and test with logic:equal or jstl c:if like this :
<c:if test="${condition}">
condition is true
</c:if>
Below the code
<tbody>
<logic:iterate name="tableList" property="list" indexId="ctr" id="e">
<tr class="text-center">
<logic:equal name="ctr" value="0" >
<td class="text-center"><bean:write name="e" property="A" /></td>
</logic:equal>
<td class="text-center"><bean:write name="e" property="B" /></td>
<td class="text-center"><bean:write name="e" property="C" /></td>
</tr>
</logic:iterate>
Related
I am using Selenium and Java to write a test. I have the DOM below:
<tbody>
<tr>
<th>Copy</th>
<th>Subfield</th>
<th>Subfield Border</th>
<th>Field</th>
<th>Field Border</th>
</tr>
<tr id="333877">
<td>
<input type="checkbox" checked="" class="copySubfieldBorderCheck"/>
</td>
<td>a</td>
<td class="s">No</td>
<td>c</td>
<td>Yes</td>
</tr>
<tr>
<th>as</th>
<th>er</th>
<th>df</th>
<th>xc</th>
<th>xc</th>
</tr>
<tr id="333877">
<td>
<input type="checkbox" checked="" class="copySubfieldBorderCheck"/>
</td>
<td>rt</td>
<td class="noBorderBoldRed">Yes</td>
<td>ff</td>
<td>sdf</td>
</tr>
I want to get the tr that has a td tag whose text is No and alos it LAST td tag's text is Yes
I am looking for something like this:
//tr[./td[text()='No'] and ./td[text()='Yes' and isLast()]]
An easy way would be to concat the 3rd and the last cell and then filter the text on NoYes:
//tr[concat(td[3], td[last()])='NoYes']
<div id="headerAgentInfoDetailsPhone">
<table>
<tr>
<td>vendor:</td><td><input type="text" /></td>
<td>vendorgroup:</td><td><input type="text" /></td>
<td>account:</td><td><input type="text" /></td>
</tr>
I have code as above. Now I want a break function after the second td. For example as follows:
<div id="headerAgentInfoDetailsPhone">
<table>
<tr>
<td>vendor:</td><td><input type="text" /></td><br />
<td>vendorgroup:</td><td><input type="text" /></td><br />
<td>account:</td><td><input type="text" /></td>
</tr>
I tried to add td:n-thchild(even):after {content: \A; white-space: pre;
text-align: justify;} but its not working. The whole content is getting displayed in a single row.
A <br /> between a </td> and a <td> cannot do anything. What do you want to do by "adding a break" ?
If you want to show each info on a separated line, you have to write a new <tr> :
<table>
<tr>
<td>vendor:</td><td><input type="text" /></td>
</tr>
<tr>
<td>vendorgroup:</td><td><input type="text" /></td>
</tr>
<tr>
<td>account:</td><td><input type="text" /></td>
</tr>
</table>
It will draw a 3 lines table, with 2 cells in each line.
Yes, <tr is table row, and <td is table data. See http://www.w3schools.com/html/html_tables.asp for explanation. In a table you can't break the row with <br>, so if you use </tr> and <tr> to start a new table row instead it will work better.
I am attempting to pull a value and a header (string) from a website, but unable to find the element using selenium.
My Code
I used Firebug to get the XPath and this is what it determined:
//*[#id="DimensionForm"]/p[1]/table/tbody/tr[3]/td[3]
Code
Dim Right as double
Dim Marker as string
Marker = selenium.findElementByXPath("//*[#id="DimensionForm"]/p[1]/table/tbody/tr[2]/td[3]").getAttribute("value")
Right = selenium.findElementByXPath("//*[#id="DimensionForm"]/p[1]/table/tbody/tr[3]/td[3]").getAttribute("value")
HTML CODE
<form id="DimensionForm" name="validate" action="Dimension" method="post">
<div style="margin-top: 7px"></div>
<p><table width="100%" cellspacing="0" border="0" cellpadding="0" class="element">
<tr>
<td> </td><td class="formtitlenobg" colspan="6" align='right'>
AREA DIMENSIONS (AREA A) <span class='quote'> Front</span> 25.24</td>
</tr>
<tr align="right">
<td class="tablerowlightgreen" width=10> </td>
<th class="formtitle" width=250 align="left">Property</th>
<th class="formtitle" width=50>Check</th> <th class="formtitle" width=75>Front</th>
<th class="formtitle" width=75>Center</th><th class="formtitle" width=75>Left</th>
<th class="formtitle" width=120>Right</th>
<th class="formtitle" width=100>Total</th>
<td class="tablerow" width=50> </td>
<td class="tablerow"> </td>
</tr>
<tr align="right" nowrap>
<td> </td>
<td class="table" align="left"><strong>
Property O</strong></td>
<td class="table">+</td>
<td class="table">10</td>
<td class="table">12</td>
<td class="table"><strong>12</strong></td>
<td class="table"><strong><font class="front">
100</font></strong></td>
<td class="table">120</td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr></table>
You have incorrectly nested quotes:
selenium.findElementByXPath("//*[#id="DimensionForm"]/p[1]/table/tbody/tr[2]/td[3]")
Perhaps you meant:
selenium.findElementByXPath("//*[#id='DimensionForm']/p[1]/table//tr[2]/td[3]")
Note the single-quotes in the second line!
Clicking on checkbox based on tables column value using Xpath. Below is the html
<table id="tblHotels">
<TBODY>
<TR>
<TH align="left">
<INPUT checkbox="" id="chkNSelectAll name=chkNSelectAll type="/>
</TH>
<TH align="left" title="Hotel">Hotel</TH>
<TH title=" align=left">
<SPAN id="spnExpandBtn">
<IMG/>
</SPAN>
</TH>
<TH align="left" title="Hotel">Hotel</TH>
<TH align="left" title="Reg Date">Reg Date</TH>
<TH align="left" title="Room Type">Room Type</TH>
<TH align="left" title="Location">Location</TH>
<TH align="left" title="Room Number">Room Number</TH>
</TR>
<TR>
<TD colSpan="11">
<IMG src=" ../NoExpiry/images/uaimBSpacer.gif"/>
</TD>
</TR>
<TR>
<TD>
<INPUT id="chkNSelect" name="chkNSelect" type="checkbox" value="on"/>
</TD>
<TD customHiddenText="">MATHEW Joe</TD>
<TD/>
<TD customHiddenText="">
<SPAN>Affray (
<STRONG/>Kim Lee)
</SPAN>
</TD>
<TD class="regDate customHiddenText=">10/01/2014</TD>
<TD customHiddenText="">1HE</TD>
<TD customHiddenText="">South West </TD>
<TD id="tdChildroom name=" tdChildroom=""/>
<INPUT id="hidYID" name="hidYID" type="hidden" value="409">
<INPUT id="hidYD" name="hidYD" type="hidden">
<INPUT id="hidYDID" name="hidYDID" type="hidden" value="1015389"/>
</INPUT>
</INPUT>
</TR>
<TR>
<TD>
<INPUT id="chkNSelect" name="chkNSelect" type="checkbox" value="on"/>
</TD>
<TD customHiddenText="">MATHEW Penny</TD>
<TD/>
<TD customHiddenText="">
<SPAN>Affray (
<STRONG/>Jim Lee)
</SPAN>
</TD>
<TD class="regDate customHiddenText=">10/01/2014</TD>
<TD customHiddenText="">1HE</TD>
<TD customHiddenText="">South West </TD>
<TD id="tdChildroom name=" tdChildroom=""/>
<INPUT id="hidYID" name="hidYID" type="hidden" value="409">
<INPUT id="hidYD" name="hidYD" type="hidden">
<INPUT id="hidYDID" name="hidYDID" type="hidden" value="1015389"/>
</INPUT>
</INPUT>
</TR>
</TBODY>
</table>
here is what i am trying and this always clicks the first checkbox??
Driver.FindElementByXPath("//td[contains(text(),'MATHEW Penny')]/preceding::td/input[#name='chkNSelect']").Click()
If i try to just find the column with the text it can find it not why it cannot find the preceding check box and jumps to first rows check box??
Driver.FindElementByXPath("//td[contains(text(),'MATHEW Penny')]
my requirement is to select the first checkbox (do something eg:add it to another table) uncheck it then check the 2nd checkbox (do something eg:add it to another table).
Use for MATHEW Penny:
//td[contains(text(),'Penny')]/preceding-sibling::td/input[#name='chkNSelect']
Use for MATHEW Joe:
//td[contains(text(),'Joe')]/preceding-sibling::td/input[#name='chkNSelect']
Its selecting all input elements with name as chkNSelect which comes before td with text as MATHEW Penny.
Use
//td[contains(text(),'MATHEW Penny')]/preceding::td/input[last()][#name='chkNSelect']
to select only first such input
You could try:
first targeting the tr
containing the td with the text node you want (using a predicate)
and then going to an input within a td in that table row
So that translates to:
Driver.FindElementByXPath("//tr[td[contains(text(),'MATHEW Penny')]]/td/input[#name='chkNSelect']")
Breakdown:
//tr[
td[
contains(text(),'MATHEW Penny')
]
]
/td/input[#name='chkNSelect']
I am working on a ONLINE Order System using visual studio as framework and asp classic and vb.net as languages combined with html and javascript. I want to make input fields of a HTML form readonly and editable on the bases of selected value of a drop down list.My code is
<table border="0" width="61.2%" align=center><tr ><td colspan=2 id="bg_page_title" align="center" valign="middle"><strong>
Product Edit Wizard
</td></tr>
<tr>
<td align="right" width="50%"><b>Product Name:</b></td>
<tr>
<td align="right" width="50%"><b>What You Want To Do:</b></td>
<td width="50%">
<select name="what_change" id="ma" onChange="changetextbox()" >
<option value="0"> Select Option</option>
<option value="1" > Bonus Changed</option>
<option value="2" > Price Changed</option>
<option value="3" > Product Discontinue</option>
<option value="4" > Product Re-Open</option>
</select>
</td></tr> <tr id=Tr1>
<td align="right" width="50%" ><b>Ex-Fact Price:</b></td>
<td width="50%">
<tr id=Tr1>
<td align="right" width="50%" ><b>Ex-Fact Price:</b></td>
<td width="50%">
<input type="text" id="ma" name="f_price" value="<%=rs("f_price")%>" > </td>
</tr>
<tr id=Tr2>
<td align="right" width="50%" ><b>Ex-Dist Price:</b></td>
<td width="50%" ><input type="text" id="ma" name="d_price" value="<%=rs("d_price")%>" > </td>
</tr>
<tr id=Tr3>
<td align="right" width="50%" ><b>Bonus Flat Rate:</b></td>
<td width="50%" ><input type="text" id="ma" name="bonus_rate" value=" <%=rs("bonus_rate")%>" </td>
</tr>
<tr id=Tr4>
<td align="right" width="50%" ><b>Bonus Scheme:</b></td>
<td width="50%" ><input type="text" id="ma" name="bonus_sch" value=" <%=rs("bonus_sch")%>" > </td></tr>
<tr id=Tr5>
<td align="right" width="50%" ><b>Bonus Units:</b></td>
<td width="50%" ><input type="text" id="ma" name="bonus_units" value="<%=rs("bonus_units")%>" > </td></tr>
I want to do that when user select 'bonus change" only relevant fields of bonus will editable and others will remain readonly. and when user select "price change" only relevant fields of price will be editable and other will change to readonly. Kindly guide me to solve my problem.
Thanx
First of all change your id's into a unique one(No elements should share the same id).
Simply add a corresponding classes on every input based on what class may be applicable for them. For example:
Class '1' is for Bonus Change
Class '2' is for Price Change
and so on...
<input type="text" id="ma" name="d_price" value="<%=rs("d_price")%>" class="1 2">
Then using JQuery:
$("#ma").change(function(){ // "ma": the id of your drop down(select)
var cls = $(this).val();
$('input').attr('disabled','disabled');
$('.'+cls).removeAttr('disabled');
});
at first change ids of input fields, id must be unique, use Jquery to do that, something like this
$(document).ready(function(){
$("#select_box_id").change(function(){
$("input[type='text']").attr('disabled','disabled');
$(".ma"+$(this).val()).removeAttr('disabled');
})
})
<table border="0" width="61.2%" align=center><tr ><td colspan=2 id="bg_page_title" align="center" valign="middle"><strong>
Product Edit Wizard
</td></tr>
<tr>
<td align="right" width="50%"><b>Product Name:</b></td>
<tr>
<td align="right" width="50%"><b>What You Want To Do:</b></td>
<td width="50%">
<select name="what_change" id="select_box_id" onChange="changetextbox()" >
<option value="0"> Select Option</option>
<option value="1" > Bonus Changed</option>
<option value="2" > Price Changed</option>
<option value="3" > Product Discontinue</option>
<option value="4" > Product Re-Open</option>
</select>
</td></tr> <tr id="Tr1">
<td align="right" width="50%" ><b>Ex-Fact Price:</b></td>
<td width="50%">
<tr id="Tr1">
<td align="right" width="50%" ><b>Ex-Fact Price:</b></td>
<td width="50%">
<input type="text" class="ma2" name="f_price" value="" /> </td>
</tr>
<tr id="Tr2">
<td align="right" width="50%" ><b>Ex-Dist Price:</b></td>
<td width="50%" ><input type="text" class="ma2" name="d_price" value="" /> </td>
</tr>
<tr id="Tr3">
<td align="right" width="50%" ><b>Bonus Flat Rate:</b></td>
<td width="50%" ><input type="text" class="ma1" name="bonus_rate" value=""/> </td>
</tr>
<tr id="Tr4">
<td align="right" width="50%" ><b>Bonus Scheme:</b></td>
<td width="50%" ><input type="text" class="ma1" name="bonus_sch" value="" /> </td></tr>
<tr id="Tr5">
<td align="right" width="50%" ><b>Bonus Units:</b></td>
<td width="50%" ><input type="text" class="ma1" name="bonus_units" value=""/> </td></tr>