hpple XPath query for complex html - html

I have a complex html file that I need to parse in Objective-C. The html looks like
<HTML>
<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10" align="left" valign="top"><img src="http://www.indianrail.gov.in/main_text_left_top2.gif" alt="" width="8" height="8"></td>
<td width="100%" align="left" valign="top" class="text_rail_top"><img src="http://www.indianrail.gov.in/blank.gif" alt="" width="1" height="8"></td>
<td width="10" align="right" valign="top"><img src="http://www.indianrail.gov.in/main_text_rgt_top2.gif"alt="" width="8" height="8" ></td>
</tr>
<tr>
<td height="400" align="right" valign="top" class="text_rail_left"></td>
<td width="100%" align="left" valign="top" class="text_back_color"><table border="0" cellPadding="0" cellSpacing="0" width="100%"><tr>
<td align="left" valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="0"><tr> <td align="middle"> <FONT SIZE = "1"> Indian Railways Online Website: <b><a TITLE = "Passenger Reservation System - CONCERT" href="http://www.indianrail.gov.in/index.html" target="_blank">http://www.indianrail.gov.in</b></a> designed and hosted by CRIS.</FONT> </td></tr></table></td>
</tr><tr>
<td align="left" valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td><table border="0" width="100%" /></td>
</tr>
<tr>
<td align="center" valign="top" class="inside_heading_text" colspan="4"><br />Trains Between A Pair of Stations </td>
</tr>
<td colspan="4"> </td>
</tr>
<tr>
<td colspan="4" align="center" valign="top" class="Enq_heading"> You Queried For <SCRIPT LANGUAGE="JavaScript" SRC= "/js/inet_srcdest.js">
function getCookie(http://www.indianrail.gov.in/tbisip_400x400.htm)</SCRIPT>
<link href="http://www.indianrail.gov.in/cris_google.css" media="all" rel="Stylesheet" type="text/css" />
<script language ="JavaScript">
var searchQuery ='MUMBAI CENTRAL DELHI '
</script><FORM NAME="Accavl" METHOD="POST" ACTION="http://www.indianrail.gov.in/cgi_bin/inet_accavl_cgi1.cgi">
<TR>
<TD valign="top"><table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table_border">
<TR class="heading_table_top">
<TH>Origin</TH>
<TH>Destination</TH>
</TR>
<TR>
<TD class="table_border_both">MUMBAI CENTRAL -[BCT ]</TD>
<TD class="table_border_both">DELHI -[DLI ]</TD>
</TR>
</TABLE>
</TD></TR>
<TR><td> </td></TR>
<TR>
<td class="main_text">Enter Quota:</td>
<td><SELECT NAME="lccp_quota" SIZE="1" >
<OPTION VALUE="CK">Tatkal Quota
<OPTION VALUE="LD">Ladies Quota
<OPTION VALUE="DF">Defence Quota
<OPTION VALUE="FT">Foreign Tourist Quota
<OPTION VALUE="SS">Lower Berth Quota$
<OPTION VALUE="YU">Yuva Quota
<OPTION VALUE="DP">Duty Pass Quota
<OPTION VALUE="HP">Handicaped Quota
<OPTION VALUE="PH">Parliament House
<OPTION selected VALUE="GN">General Quota
</SELECT></TD></tr>
<tr>
<td class="main_text">Journey Date:</td><td><INPUT NAME="lccp_day" SIZE="2" VALUE="11" onchange="return changedate()"><SELECT NAME="lccp_month" SIZE="1" onClick="return changedate()"><OPTION selected VALUE="5">May<OPTION VALUE="6">Jun<OPTION VALUE="7">Jul</SELECT></TD></tr><INPUT TYPE="HIDDEN" NAME="lccp_classopt" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class1" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class2" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class3" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class4" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class5" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class6" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class7" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class8" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class9" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_cls10" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_age" SIZE="2" VALUE="ADULT_AGE"><tr>
<td> </td><td><INPUT TYPE="Button" CLASS="btn_style" NAME="lccp_submitacc" ONCLICK="return submitavailability(0)" VALUE="Get Availability"> <INPUT TYPE="Button" CLASS="btn_style" NAME="lccp_submitfare" ONCLICK="return submitfare(0)" VALUE="Get Full Fare"> <INPUT TYPE="Button" CLASS="btn_style" NAME="lccp_submitpath" ONCLICK="return submitroute(0)" VALUE="Get Schedule"> <INPUT TYPE="BUTTON" CLASS="btn_style" NAME="lccp_submitrun" ONCLICK="return submitrun(0)" VALUE="Get Running Status"></td></tr></table><br>
<TABLE BORDER ALIGN=center><TABLE width="98%" border="1" bordercolor="#993300" align="center" cellpadding="3" cellspacing="1" class="table_border_both_left"><tr class="heading_table_top">
<TH ROWSPAN = 2 width="9%" >Train No.</TH>
<TH ROWSPAN = 2 width="20%" >Train Name</TH>
<TH ROWSPAN = 2 width="15%" >Origin</TH>
<TH ROWSPAN = 2 width="8%" >Dep.Time</TH>
<TH ROWSPAN = 2 width="14%" >Destination</TH>
<TH ROWSPAN = 2 width="7%" >Arr.Time</TH>
<TH COLSPAN = 7 width="7%" >Days Of Run</TH>
<TH COLSPAN = 10 width="7%">Classes</TH>
</TR>
<TR class="heading_table_top">
<TH width="3%">M</TH>
<TH width="3%">T</TH>
<TH width="3%">W</TH>
<TH width="3%">T</TH>
<TH width="3%">F</TH>
<TH width="3%">S</TH>
<TH width="3%">S</TH>
<TH width="3%">1A</TH>
<TH width="3%">2A</TH>
<TH width="3%">FC</TH>
<TH width="3%">3A</TH>
<TH width="3%">CC</TH>
<TH width="3%">SL</TH>
<TH width="3%">2S</TH>
<TH width="3%">3E</TH>
</TR>
<TR><TD><INPUT TYPE="RADIO" NAME="lccp_trndtl" VALUE="19019BDTSNZM YYYYYYYY "ONCLICK="return farefill('19019BDTSNZM YYYYYYYY ','19019','BDTS',0,0,1,0,1,0,1,0,0,0,0)" CHECKED>19019</TD>
<TD ALIGN =Center TITLE = " Please look the following same trains list also ">+DEHRADUN EXP <A NAME="BACKSAMETRN"></A>
<TD ALIGN =Center TITLE="Station CodeBDTS">BANDRA TERMINUS</TD>
<TD ALIGN = Center>00:05</TD>
<TD ALIGN = Center TITLE="Station Code NZM ">H NIZAMUDDIN </TD>
<TD ALIGN = Center>05:25</TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD>-</TD>
<TD><INPUT TYPE="RADIO" Name="lccp_class2" VALUE="2A" ONCLICK="return deselectclass(1,0,1,0,1,0,1,0,0,0,0,'N','Y','N','N','N','N','N','N','N','N')" CHECKED>
<TD>-</TD>
<TD><INPUT TYPE="RADIO" Name="lccp_class4" VALUE="3A" ONCLICK="return deselectclass(1,0,1,0,1,0,1,0,0,0,0,'N','N','N','Y','N','N','N','N','N','N')">
<TD>-</TD>
<TD><INPUT TYPE="RADIO" Name="lccp_class6" VALUE="SL" ONCLICK="return deselectclass(1,0,1,0,1,0,1,0,0,0,0,'N','N','N','N','N','Y','N','N','N','N')">
<TD>-</TD>
<TD>-</TD>
</TR></FONT>
<TR><TD><INPUT TYPE="RADIO" NAME="lccp_trndtl" VALUE="19023BCT NDLSYYYYYYYY "ONCLICK="return farefill('19023BCT NDLSYYYYYYYY ','19023','BCT ',0,0,0,0,0,0,2,1,0,0,0)">19023</TD>
<TD ALIGN =Center TITLE = " Please look the following same trains list also ">+FZR JANATA EXP <A NAME="BACKSAMETRN"></A>
<TD ALIGN =Center TITLE="Station CodeBCT ">MUMBAI CENTRAL </TD>
<TD ALIGN = Center>07:25</TD>
<TD ALIGN = Center TITLE="Station Code NDLS">NEW DELHI </TD>
<TD ALIGN = Center>12:45</TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD><INPUT TYPE="RADIO" Name="lccp_class6" VALUE="SL" ONCLICK="return deselectclass(2,0,0,0,0,0,2,1,0,0,0,'N','N','N','N','N','Y','N','N','N','N')">
<TD><INPUT TYPE="RADIO" Name="lccp_class7" VALUE="2S" ONCLICK="return deselectclass(2,0,0,0,0,0,2,1,0,0,0,'N','N','N','N','N','N','Y','N','N','N')">
<TD>-</TD>
</TR></FONT>
</TABLE>
</BODY>
</HTML>
I want to parse the html using hpple for the following output
19019
BANDRA TERMINUS
00:05
H NIZAMUDDIN
05:25
2A
3A
SL
19023
MUMBAI CENTRAL
07:25
NEW DELHI
12:45
SL
2S
I started with the following xpath query
NSString *tutorialsXpathQueryString = #"//table[#class='table_border_both_left']//td";
But it returns way to many results and is difficult to parse further. Can someone help me with the xpath query so I can parse this more efficiently.
Thanks!

You can locate table rows with this:
List<WebElement> tableRows = findElements(By.xpath("//TABLE[#class='table_border_both_left']//tr[not(#class='heading_table_top')]"));
In a row find the expected data :
for (WebElement row : tableRows) {
String trainNo = row.findElement(By.xpath("td[1]")).getText(); //or use xpath : td[1]/text()
String origin = row.findElement(By.xpath("td[3]")).getText(); //or use xpath : td[3]/text()
String deptTime = row.findElement(By.xpath("td[4]")).getText(); //or use xpath : td[4]/text()
String destination = row.findElement(By.xpath("td[5]")).getText(); //or use xpath : td[5]/text()
String arrTime = row.findElement(By.xpath("td[6]")).getText(); //or use xpath : td[6]/text()
List<WebElement> radioButtons = row.findElements(By.xpath("td//input[not(#name='lccp_trndtl')]"));
// or use xpath : //TABLE[#class='table_border_both_left']//tr[not(#class='heading_table_top')]//td//input[not(#name='lccp_trndtl')]//#value
for (WebElement radio : radioButtons) {
String value = radio.getAttribute("value");
}
}
Sorry for my code but I'm using Selenium WebDriver in Java. I hope the given xpath expressions will be useful.

You can use an XPath union expression (i.e. |) to return the direct text() children of your TD elements and also the #VALUE attribute of your INPUT elements:
//TABLE[#class='table_border_both_left']//TD(text() | INPUT[#TYPE eq "RADIO"]/#VALUE)

Related

select various options from drop down box in vba

How can I change the option for Customer dropdown menu as shown in the HTML sample below and then click submit?
I need to change the selected value from:
Diamond State Generation Partner (Brookside) (LVG- QFTP-RC)
To
Diamond State Generation Partners (Red Lion) (LVG- QFTP-RC)
and then click submit.
Attempts:
My attempts are shown below.
on the following line:
MyBrowser.document.querySelector("option[value=1745]").Selected = True
error That yielded
"Run-time error ' -2147352319 (80020101)': Method ' querySelector' of
object 'JScriptTypeInfo' failed.
Code:
Sub daily()
Dim HMTLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Dim MyHTML_Element As IHTMLElement
Dim MYURL As String
' website
MYURL = "website"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MYURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
' user login and password
HTMLDoc.all.user_login.Value = "username"
HTMLDoc.all.user_password.Value = "password"
HTMLDoc.forms(0).submit
While MyBrowser.Busy Or MyBrowser.readyState < 4: DoEvents: Wend
' click reports
HTMLDoc.getElementsByClassName("menuitem")(1).Click
While MyBrowser.Busy Or MyBrowser.readyState < 4: DoEvents: Wend
'click Billing Analysis Report (Industrial)
HTMLDoc.getElementsByClassName("firstlink")(0).Click
'click to submit to get to billing analysis report
With MyBrowser.document
.querySelector("select[name=vsCustKy]").Click
'I receive the error message on the next line below
.querySelector("option[value=1745]").Selected = True
.querySelector("select[name=vsCustKy]").FireEvent "onchange"
End With
HTMLDoc.forms(0).submit
End Sub
Full HTML:
</SCRIPT>
<LINK rel="stylesheet" href="https://www.conectiv.com/cpd/cpd_stylesheet.css">
</HEAD>
<BODY bgcolor="#ffffff" leftmargin="0" marginwidth="0" marginheight="0" topmargin="0" background="https://www.conectiv.com/images/big_c_bg.gif" bgproperties="fixed" vlink="#1f969b" link="#1f969b" onLoad="window.query_form.vsReportMonth.focus();">
<!-- Begin: CPD Navigation Header -->
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td nowrap valign="bottom"><img src="https://webapps.delmarva.com/images/delmarva_logo.png" border="0" align="middle" alt="Delmarva Power"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<!-- End: CPD Navigation Header -->
<TABLE border="1" cellpadding="6" cellspacing="0" width="100%" bordercolor="#cccccc">
<TR>
<td colspan="1" align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="middle" nowrap>
Trader Home<span class="body"> | </span>
Transaction<span class="body"> | </span>
Reports
</td>
</tr>
</table>
</td>
</TR>
<TR>
<TD>
<CENTER>
<BR>
<TABLE WIDTH=500 CELLSPACING=0>
<TR>
<TH VALIGN=TOP ALIGN=LEFT>
<FONT COLOR="BLUE" FACE="Arial, Helvetica" SIZE="4">
<B>INPUT THE MONTH & YEAR :</B>
</FONT>
</TH>
</TR>
</TABLE>
<FORM ACTION="gso_billing_analysis_report" METHOD="POST" NAME="query_form" onSubmit="return verify_entries();">
<INPUT TYPE="hidden" NAME="vsCurrUser" VALUE="2753">
<INPUT TYPE="hidden" NAME="vsTransactionName" VALUE="INTER_BILLING_ANALYSIS_REPORT">
<TABLE WIDTH=500 CELLSPACING=0>
<TR>
<TD>
<TABLE WIDTH=500 BGCOLOR="#FFFFFF" BORDER=1 CELLSPACING=0>
<TR>
<TD ALIGN=LEFT VALIGN=TOP>
<TABLE WIDTH=500 CELLSPACING=0>
<TR>
<TD ALIGN=LEFT COLSPAN=2>
<FONT COLOR="BLUE" FACE="Arial, Helvetica" SIZE="2">
</FONT>
</TD>
</TR>
<TR>
<TD WIDTH=200 ALIGN=RIGHT VALIGN=CENTER>
<FONT COLOR="BLACK" FACE="Arial, Helvetica" SIZE="2">
<B>MONTH : </B>
</FONT>
</TD>
<TD WIDTH=300 ALIGN=LEFT VALIGN=CENTER>
<SELECT NAME="vsReportMonth">
<OPTION VALUE=1>January
<OPTION VALUE=2>February
<OPTION VALUE=3>March
<OPTION VALUE=4>April
<OPTION VALUE=5>May
<OPTION VALUE=6>June
<OPTION VALUE=7>July
<OPTION SELECTED VALUE=8>August
<OPTION VALUE=9>September
<OPTION VALUE=10>October
<OPTION VALUE=11>November
<OPTION VALUE=12>December
</SELECT>
</TD>
</TR>
<TR>
<TD ALIGN=LEFT COLSPAN=2>
<FONT COLOR="BLUE" FACE="Arial, Helvetica" SIZE="2">
</FONT>
</TD>
</TR>
<TR>
<TD WIDTH=200 ALIGN=RIGHT VALIGN=CENTER>
<FONT COLOR="BLACK" FACE="Arial, Helvetica" SIZE="2">
<B>YEAR : </B>
</FONT>
</TD>
<TD WIDTH=300 ALIGN=LEFT VALIGN=CENTER>
<FONT COLOR="BLACK" FACE="Arial, Helvetica" SIZE="2">
<INPUT TYPE="TEXT" NAME="vsReportYear" VALUE="2018" SIZE=4 MAXLENGTH=4>
</FONT>
</TD>
</TR>
<TR>
<TD ALIGN=LEFT COLSPAN=2>
<FONT COLOR="BLUE" FACE="Arial, Helvetica" SIZE="2">
</FONT>
</TD>
</TR>
<TR>
<TD WIDTH=200 ALIGN=RIGHT VALIGN=TOP>
<FONT COLOR="BLACK" FACE="Arial, Helvetica" SIZE="2">
<B>CUSTOMER : </B>
</FONT>
</TD>
<TD WIDTH=300 ALIGN=LEFT VALIGN=TOP>
<FONT COLOR="BLACK" FACE="Arial, Helvetica" SIZE="2">
<SELECT NAME="vsCustKy">
<OPTION SELECTED VALUE=1705>Diamond State Generation Partner (Brookside) (LVG- QFTP-RC)
<OPTION VALUE=1745>Diamond State Generation Partners (Red Lion) (LVG- QFTP-RC)
</SELECT>
</FONT>
</TD>
</TR>
<TR>
<TD ALIGN=LEFT COLSPAN=2>
<FONT COLOR="BLUE" FACE="Arial, Helvetica" SIZE="2">
</FONT>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<INPUT TYPE="submit" VALUE="Continue">
</TD>
</TR>
<TR>
<TD ALIGN=LEFT COLSPAN=2>
<FONT COLOR="BLUE" FACE="Arial, Helvetica" SIZE="2">
</FONT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
<!-- Begin: CPD Navigation Footer -->
<tr>
<td colspan="1" align="center">
<table border="0" width="100%">
<tr>
<td align="center"><span class="caption">Copyright: 2018 Delmarva Power. All rights reserved</span></td>
</tr>
</table>
</td>
</tr>
</TABLE>
</BODY>
</HTML>
That error is due to missing the '' to surround the number. There is also a form to navigate.
MyBrowser.document.getElementsByTagName("form")(0).querySelector("option[value='1745']").Selected = True
You may need to ensure there is a wait before attempting to select. Traditionally a
While MyBrowser.Busy Or MyBrowser.Busy.readyState < 4: DoEvents: Wend
before is good and after any click events.
You can also use a loop to wait until element is present, with time out.
Const WAIT_TIME_SECS As Long = 5
Dim t As Date, ele As Object
t = Timer
Do
DoEvents
On Error Resume Next
Set ele = MyBrowser.document.getElementsByTagName("form")(0).querySelector("option[value='1745']").
On Error GoTo 0
If Timer - t > WAIT_TIME_SECS Then Exit Do
Loop While ele Is Nothing
If Not ele Is Nothing Then ele.Selected = True

Hide/Show Table based off of drop down menu selection HTML

I'm trying to hide the second table below and make it appear when customers select the debit option from the drop down menu at the top. I'm relatively new to this so any help is greatly appreciated!
<table width="723" height="75" border="2">
<tbody>
<tr>
<th width="248" scope="col"><span style="font-size: 13px">Payment
Method:</span>
<select>
<option value=""></option>
<option value="tracer ach credit">Credit</option>
<option value="tracer ach debit">Debit</option>
</select> </th>
</tr>
</tbody>
</table>
<br>
<table width="723" height="558" border="2">
<tbody>
<tr style="text-align: center; font-size: 13px;">
<td height="40" colspan="2">
</td>
</tr>
<tr>
<td height="24" valign="top"><span style="font-size: 13px">Bank
Account:</span>
</td>
<td height="26"><textarea rows="1" cols="50">
</textarea> </td>
</td>
<span style="text-align: center">
</div>
</span>
</tr>
</tbody>
</table>
Add id="table2" to your table and this CSS to start hidden:
#table2 {
visibility:hidden;
}
And add to your <select> the onchange="ShowHide(this)" every change in select call the ShowHide function.
With javascript add this function to turn visible the table if the option selected is debit:
function ShowHide(select){
var table2 = document.getElementById("table2");
if(select.value == "tracer ach debit"){
table2.style.visibility="visible";
}else{
table2.style.visibility="hidden";
}
}
Online example:
function ShowHide(select){
var table2 = document.getElementById("table2");
if(select.value == "tracer ach debit"){
table2.style.visibility="visible";
}else{
table2.style.visibility="hidden";
}
}
#table2 {
visibility:hidden;
}
<table width="300" height="75" border="2">
<tbody>
<tr>
<th scope="col">
<span style="font-size: 13px">Payment Method:</span>
<select id="select" onchange="ShowHide(this)">
<option value=""></option>
<option value="tracer ach credit">Credit</option>
<option value="tracer ach debit">Debit</option>
</select>
</th>
</tr>
</tbody>
</table>
<br>
<table width="300" height="300" border="2" id="table2">
<tbody>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td valign="top">
<span style="font-size: 13px">Bank Account:</span>
</td>
<td>
<textarea rows="1" cols="30"></textarea>
<span></span>
</td>
</tr>
</tbody>
</table>
function paymentChangeHandler(event) {
var value = event.target.value;
var bank = document.getElementById("bank_info");
if (value.indexOf('debit') !== -1) {
bank.style.visibility = "visible";
} else {
bank.style.visibility = "hidden";
}
}
var selector = document.getElementById("payment_method");
selector.onchange = paymentChangeHandler;
<table width="723" height="75" border="2">
<tbody>
<tr>
<th width="248" scope="col"><span style="font-size: 13px">Payment
Method:</span>
<select id="payment_method">
<option value=""></option>
<option value="tracer ach credit">Credit</option>
<option value="tracer ach debit">Debit</option>
</select> </th>
</tr>
</tbody>
</table>
<br>
<table width="723" height="558" border="2" id="bank_info" style="visibility:hidden;">
<tbody>
<tr style="text-align: center; font-size: 13px;">
<td height="40" colspan="2">
</td>
</tr>
<tr>
<td height="24" valign="top"><span style="font-size: 13px">Bank
Account:</span>
</td>
<td height="26"><textarea rows="1" cols="50">
</textarea> </td>
<span style="text-align: center">
</span>
</tr>
</tbody>
</table>
Add id's for payment method drop down control and bank table and add style visibility:hidden to bank table.

My form answers are not attaching to email

I have wrote in scripting a simple question list, I need the responses to be returned in a txt file via email when the person hits submit. The front end of the file works, the email creates but the form does not post. Can anyone help with this scripting please?
Coding listed below:
<form action="mailto:test#yahoo.com?subject=Test" id="form" method="post" name="form" >
<!-- PAGE HEADER -->
<table bgcolor=#D1DEE5>
<tr>
<td width="833px"align="center">
<input class="title" name="Title" value="Customer Satisfaction Survey">
</td>
</tr>
</table>
<!-- QUESTIONS -->
<p>
<table>
<tr>
<td>
<p> Welcome message
<p>
</ul>
</td>
</tr>
</table>
<br>
<table>
<tr class="shaded">
<td align="left">
<p><b>Please tell us based on your experience, how satisfied you are with the following services:</b>
</td>
<td align="center" width="50px">Very satisfied</td>
<td align="center" width="50px">Satisfied</td>
<td align="center" width="50px">Dissatisfied</td>
<td align="center" width="50px">Very Dissatisfied</td>
<td align="center" width="50px">N/A</td>
</tr>
<tr>
<td>A</td>
<td align="center" width="50px"><input type="radio" name="q1" value="Very satisfied"></td>
<td align="center" width="50px"><input type="radio" name="q1" value="Satisfied"></td>
<td align="center" width="50px"><input type="radio" name="q1" value="Dissatisfied"></td>
<td align="center" width="50px"><input type="radio" name="q1" value="Very Dissatisfied"></td>
<td align="center" width="50px"><input type="radio" name="q1" value="N/A"></td>
</tr>
</table>
<br>
<table class="outlineTable" bgcolor=#D1DEE5>
<tr>
<td align="left" rowspan=5 width=500 style="vertical-align:top" style="padding-top:5px">
<p><b>Please add comments to explain your answers</b>
<br><textarea name="Comments10" id="Comments10" rows="7" cols="55"></textarea>
</td>
<td align="left">
Month being scored
</td>
<td align="left" class="submitButton">
<input class="name" name="Month">
</td>
</tr>
<tr>
<td align="left">
Name
</td>
<td align="left" class="submitButton">
<input class="name" name="Name">
</td>
</tr>
<tr>
<td align="left">
Date
</td>
<td align="left" class="submitButton">
<input class="name" name="Date">
</td>
</tr>
<tr>
<td align="left">
</td>
<td align="left" class="submitButton">
<input class="button2" type="submit" value="Click here to submit results">
</td>
</tr>
</table>
<br>
<table bgcolor=#D1DEE5>
<tr>
<td align="center">
<h1> Many thanks for taking the time to complete this survey
</td>
</tr>
</table>
<p>
</form>
</body>
</html>

Select Link after fetching label in front of it

I am writing a selenium java code and at a particular webpage i want to select a link from a group of links where each link has an emebeded text within a table. How can i select particular link at this situtation. for eg.
run title--text 1
run title--text 2
run title--text 3
how can select specific run link for a specific title text? the text is not a label rather it is just simple text on the webpage.
i am using the following code:
verify.text("text 1");
it will only verify the presence of text, it wont go towards the link as link of every execution is named RUN. so it will identify the corresponding run link? The HTML code for the above is:
<HTML>
<HEAD>
<TITLE>TEST</TITLE>
</HEAD>
<BODY>
<div align="center"><table class="module" width="630">
<tr>
<th class="banner" width="70">ACTION</th>
<th class="banner" width="560">REPORT TEMPLATE</th>
</tr>
<tr>
<td class="modulenav" width="70">
<table class="innermodule" width="100%">
<tr><td class="moduleNav"><a class="listingLink"
href="www.abc.com/">Run</a></td></tr>
<tr><td class="moduleNav"><a class="listingLink"
href="www.zxc.com">UnShare</a></td></tr>
</table>
</td>
<td>
<table class="innerModule" width="100%">
<tr>
<td class="label" width="70">Title</td>
<td width="490"><span class="listingHead">Incident Performance by Priority</span></td>
</tr>
<tr>
<td class="Label" width="70">Description</td>
<td class="listing"></td>
</tr>
<tr>
<td class="Label" width="70">Owner</td>
<td class="listing"> Software Engineer Tel: </td>
</tr>
<tr>
<td class="Label" width="70">Shared With</td>
<td class="listing">
Software Engineer Tel: <br>
</td>
</tr>
<tr>
<td class="label">Report Type</td>
<td class="listing">Performance by Priority</td>
</tr>
</table>
</td>
</tr>
<tr><td class="tableRuleNavy" colspan="2"></td></tr>
<tr>
<td class="modulenav" width="70">
<table class="innermodule" width="100%">
<tr><td class="moduleNav"><a class="listingLink"
href="www.abc.com">Run</a></td></tr>
<tr><td class="moduleNav"><a class="listingLink"
href="www.cxd.com">UnShare</a></td></tr>
</table>
</td>
<td>
<table class="innerModule" width="100%">
<tr>
<td class="label" width="70">Title</td>
<td width="490"><span class="listingHead">Incident Trend Analysis Report</span></td>
</tr>
<tr>
<td class="Label" width="70">Description</td>
<td class="listing"></td>
</tr>
<tr>
<td class="Label" width="70">Owner</td>
<td class="listing">Software Engineer Tel: </td>
</tr>
<tr>
<td class="Label" width="70">Shared With</td>
<td class="listing">
Software Engineer Tel: <br>
</td>
</tr>
<tr>
<td class="label">Report Type</td>
<td class="listing">Trend Analysis</td>
</tr>
</table>
</td>
</tr>
<tr><td class="tableRuleNavy" colspan="2"></td></tr>
<tr>
<td class="modulenav" width="70">
<table class="innermodule" width="100%">
<tr><td class="moduleNav"><a class="listingLink"
href="www.sdfds.com">Run</a></td></tr>
<tr><td class="moduleNav"><a class="listingLink"
href="www.asdg.com">UnShare</a></td></tr>
</table>
</DIV>
</td>
</BODY>
</HTML>
Get a list of web elements and iterate over them.
This is not tested
E.g.
List<WebElement> we = findElements(By.cssSelector("tr a"));
Iterator itor = we.iterator()
While(itor.hasNext()) {
WebElement we = itor.next();
if (we.getText().equals("your visible text")) {
we.click // click link
}
}

not able to hide div

I have combo box which needs to be displayed based on the option i select,
but when i set display none to div it is not getting hidden. what could be the problem.
below is the html code and java script
<div id="addBanks" style="display: none" style="overflow: auto;height: 75%">
<table id="commonBodyTable" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<table width="100%" align="center" class="tableBorder2" border="0" cellpadding="2" cellspacing="0">
<tr>
<td colspan="4" class="mainheader">Add Banks</td>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign">Bank Code</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="bankcode" id="bankcode" maxlength="20" /></td>
</tr>
<tr class="lightrow">
<td width="30%" class="textalign">Bank Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="bankname" id="bankname" maxlength="20" /></td>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign">Branch Code</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="branchcode" id="branchcode" maxlength="20" /></td>
</tr>
<tr class="lightrow">
<td width="30%" class="textalign">IFSC Code</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="ifsccode" id="ifsccode" maxlength="20" /></td>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign">Country</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" class="textfieldalign"><select class="combobox" name="countryid" id="countryid" onchange="getStates(this.value)">
<option value="" >- - - Select Country Name - - -</option>
</select></td>
</tr>
<tr class="lightrow">
<td width="30%" class="textalign">State</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" class="textfieldalign"><select class="combobox" name="stateid" id="stateid">
<option value="" >- - - Select State Name - - -</option>
</select></td>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign">District Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="districtid" id="districtid">
<option value="" >- - - Select District Name - - -</option>
</select></td>
</tr>
<tr class="lightrow">
<td width="30%" class="textalign">Town or Village</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign">
Town <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="townOpt" onclick="enableVillageOrTown(this)"/>
Village <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="villageOpt" onclick="enableVillageOrTown(this)"/>
</td>
</tr>
<div id="villageDiv" style="display: none;">
<tr class="darkrow">
<td width="30%" class="textalign">Village Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="villageid" id="villageid">
<option value="" >- - - Select Village Name - - -</option>
</select></td>
</tr>
</div>
<tr class="darkrow">
<div id="townDiv" style="display: none;">
<td width="30%" class="textalign">Town Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="townid" id="townid">
<option value="" >- - - Select Town Name - - -</option>
</select></td>
</div>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign"> </td>
<td width="5%" class="mandatory"> </td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="button" class="submitbu" name="save" id="save" value="Save" onclick="saveState()">
<input type="button" class="submitbu" name="cancel" id="cancel" value="Cancel" onclick="cancelAddState();"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
and my java script :
function enableVillageOrTown(opt){
var optionValue = opt.value;
if(optionValue=='townOpt'){
document.getElementById("townDiv").style.display = "";
document.getElementById("villageDiv").style.display = 'none';
}
if(optionValue=='villageOpt'){
document.getElementById("villageDiv").style.display = "";
document.getElementById("townDiv").style.display = 'none';
}
}
UPDATE :
<div id="villageDiv" style="display: none;">
<tr class="darkrow">
<td width="30%" class="textalign">Village Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="villageid" id="villageid">
<option value="" >- - - Select Village Name - - -</option>
</select></td>
</tr>
</div>
also this is not properly aligned when
<tr class="lightrow">
<td width="30%" class="textalign">Town or Village</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign">
Town <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="townOpt" onclick="enableVillageOrTown(this)"/>
Village <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="villageOpt" onclick="enableVillageOrTown(this)"/>
</td>
</tr>
this is not hidden when the page first time loads
Please help me to find the problem
Regards
Try this code, if it works for you
function enableVillageOrTown(opt){
var optionValue = opt.value;
if(optionValue=='townOpt'){
document.getElementById("townDiv").style.display = "";
document.getElementById("villageDiv").style.display = "none";
}
if(optionValue=='villageOpt'){
document.getElementById("villageDiv").style.display = "";
document.getElementById("townDiv").style.display = "none";
}
}
For that your should use this code for HTML
<!--<div >-->
<tr class="darkrow" id="villageDiv" style="display: none;">
<td width="30%" class="textalign">Village Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="villageid" id="villageid">
<option value="" >- - - Select Village Name - - -</option>
</select></td>
</tr>
<!--</div>-->
Remove the DIVs that you are trying to manipulate and just hide or show the TRs that contain the drop downs.
I have tried the code you provided and the results are correct: http://jsfiddle.net/6mKtZ/
...meaning that div id="villageDiv" style="display: none;" is hidden and the only thing that shows up on the page is "?"