Struts 2 - Unexpected Exception caught setting 'xx' - java

I am trying to submit unknown number input from HTML Form to Action class and fetch the Input parameter information by using request Method(Used ServletActionContext) in the Action class.
But its throwing
Unexpected Exception caught setting 'xx' on 'class classname Error setting expression 'xx' with value ['yy', ]
Since input elements in the form are adding dynamically using JS, i am not in the position to have getters and setters in the Action class.
How to process the Action class without any exceptions?
JSP:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Team Activity Log</title>
<SCRIPT language="javascript">
function addRow(tableid)
{
var table = document.getElementById(tableid);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var element1 = document.createElement("select");
element1=document.getElementById("sele").cloneNode(true);
element1.type="select";
cell1.appendChild(element1);
var cell2=row.insertCell(1);
var element2 = document.createElement("input");
element2.type="text";
element2.setAttribute("placeholder","E.g:1234");
cell2.appendChild(element2);
var cell3=row.insertCell(2);
var element3 = document.createElement("input");
element3.type="text";
element3.setAttribute("placeholder","Brief your work");
cell3.appendChild(element3);
var cell4=row.insertCell(3);
var element4 = document.createElement("input");
element4.type="text";
element4.setAttribute("placeholder","MM min");
cell4.appendChild(element4);
var cell5=row.insertCell(4);
var element5 = document.createElement("img");
element5.src="close.png";
element5.setAttribute("id","delete");
element5.setAttribute("onclick","changeImage(this)");
cell5.appendChild(element5);
}
function changeImage(temp)
{
(temp.parentElement).parentElement.remove();
}
function convert(tableid,temp2)
{
var table=document.getElementById(tableid);
console.log(table.rows.length);
var hidelement=document.getElementById(temp2);
hidelement.setAttribute("value",table.rows.length-1);
for(var i=1;i<table.rows.length;i++)
{
var tt="tt"+i;
var rf="rf"+i;
var des="des"+i;
var eff="eff"+i;
console.log("executing function");
var elemen=table.rows[i].cells[0].querySelector("*");
elemen.setAttribute("name",tt);
elemen=table.rows[i].cells[1].querySelector("*");
elemen.setAttribute("name",rf);
elemen=table.rows[i].cells[2].querySelector("*");
elemen.setAttribute("name",des);
elemen=table.rows[i].cells[3].querySelector("*");
elemen.setAttribute("name",eff);
}
}
</script>
</head>
<body>
<INPUT type="button" value="Add Row" onclick="addRow('matrix')" />
<%# taglib uri="/struts-tags" prefix="s" %>
<s:url id="myActionUrl" action="timesheetprocess" />
<form action=<s:property value="%{myActionUrl}" />>
<input type="hidden" id="taskcount" value="5">
<table id="matrix">
<tr>
<th>Task Type</th>
<th>Reference ID</th>
<th>Description</th>
<th>Efforts</th>
<th></th>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr><tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
</table>
<INPUT type="button" value="Submit" onclick="convert('matrix','taskcount')" />
</form>
</body>
</html>
Action tag in struts.xml
<action name="timesheetprocess" class="com.App.Controller.Timesheet.Timeprocess"
method="execute">
<result name="success">Time.jsp</result>
</action>
My Action class:
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
public class Timeprocess {
public String execute() {
HttpServletRequest request = ServletActionContext.getRequest();
String tt="tt";
String rf="rf";
String des="des";
String eff="eff";
for(int i=0;i<Integer.parseInt(request.getParameter("taskcount"));i++)
{
System.out.println("Task Type :"+ request.getParameter(tt+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(rf+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(des+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(eff+String.valueOf(i)));
}
return "success";
}
}

You can control the process of parameters population by Struts2 via overriding interceptors in the action config.
<action name="timesheetprocess" class="com.App.Controller.Timesheet.Timeprocess"
method="execute">
<interceptor-ref name="defaultStack">
<param name="params.excludeParams">.*</param>
</interceptor-ref>
<result name="success">Time.jsp</result>
</action>
There you modify the excludeParams property of the params interceptor to exclude all parameters from processing via OGNL.
You should not get any exception in this way, but make sure you have configured struts.devMode=false
<constant name="struts.devMode" value="false" />
It should remove unnecessary warnings from the output. If you still get any warnings or exceptions in the log, then you should configure your logging framework to suppress those warnings or errors from the output.

Related

Display new select field if previous select field option is chosen

image of form showing misplaced dropdown field
i have used SO to create some script that shows/hides a div containing a field if the value of a previous field is "UpperGI". This works fine, but what i cannot do is use tr or td tags within the div.
I want the new field to be displayed in a simple table as the previous fields are.
function yesnoCheck(that) {
if (that.value == "UpperGI") {
document.getElementById("ifYes").style.display = '';
} else {
document.getElementById("ifYes").style.display = "none";
}
}
<form name="frm1" action="https://api-mapper.clicksend.com/http/v2/send.php" method="post">
<table style="width:50%">
<tr>
<td>MRN:</td>
<td><input name="customstring" id="mrn" type="text" /></td>
</tr>
<tr>
<td>Specialty:</td>
<td><select id="specialty" onchange="yesnoCheck(this);">
<option value="Breast">Breast</option>
<option value="UpperGI">UpperGI</option>
<option value="Vascular">Vascular</option>
<option value="Unknown">Unknown</option></select>
</td>
</tr>
<tr><td>
<div id="ifYes">
Select Operation:
<select id="Operation">
<option value="LapChole">Lap Chole</option>
</div>
</td></tr>
<tr>
<td></td>
<td><input type="button" value="SUBMIT" onClick="doall()"></td>
</tr>
</table>
</form>
Can anyone tell me what i am doing wrong?
<tr> it's your row, <td> your case.
You can add some css to fix col size
<script>
function yesnoCheck(that) {
if (that.value == "UpperGI") {
document.getElementById("ifYes").style.display = '';
} else {
document.getElementById("ifYes").style.display = "none";
}
}
</script>
<form name="frm1" action="https://api-mapper.clicksend.com/http/v2/send.php" method="post">
<table style="width:50%">
<tr>
<td>MRN:</td>
<td><input name="customstring" id="mrn" type="text" /></td>
</tr>
<tr>
<td>Specialty:</td>
<td><select id="specialty" onchange="yesnoCheck(this);">
<option value="Breast">Breast</option>
<option value="UpperGI">UpperGI</option>
<option value="Vascular">Vascular</option>
<option value="Unknown">Unknown</option></select>
</td>
</tr>
<tr id="ifYes" style="display: none">
<td>Select Operation:</td>
<td>
<select id="Operation">
<option value="LapChole">Lap Chole</option>
</select>
</td></tr>
<tr>
<td></td>
<td><input type="button" value="SUBMIT" onClick="doall()"></td>
</tr>
</table>
</form>

Unable to click on dynamic generating checkbox

I have a table of generating the dynamic checkboxes as below:
<div style="background: #fff;">
<div class="modal-body">
<table class="table no-margin">
<thead>
<tr>
<th>Select</th>
<th>Group Name</th>
<th>Contacts</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="checkbox checkbox-styled">
<label>
<input type="checkbox" class="datacontact" onchange="SelectContacts(this);" data-listid='1' data-grpname='Newsletter' />
</label>
</div>
</td>
<td>Newsletter</td>
<td>0</td>
</tr>
<tr>
<td>
<div class="checkbox checkbox-styled">
<label>
<input type="checkbox" class="datacontact" onchange="SelectContacts(this);" data-listid='2' data-grpname='Website Leads Buyer' />
</label>
</div>
</td>
<td>Website Leads Buyer</td>
<td>0</td>
</tr>
<tr>
<td>
<div class="checkbox checkbox-styled">
<label>
<input type="checkbox" class="datacontact" onchange="SelectContacts(this);" data-listid='3' data-grpname='Website Leads Seller' />
</label>
</div>
</td>
<td>Website Leads Seller</td>
<td>2</td>
</tr>
<tr>
<td>
<div class="checkbox checkbox-styled">
<label>
<input type="checkbox" class="datacontact" onchange="SelectContacts(this);" data-listid='4' data-grpname='Website Leads Investor' />
</label>
</div>
</td>
<td>Website Leads Investor</td>
<td>0</td>
</tr>
<tr>
<td>
<div class="checkbox checkbox-styled">
<label>
<input type="checkbox" class="datacontact" onchange="SelectContacts(this);" data-listid='5' data-grpname='Website Leads' />
</label>
</div>
</td>
<td>Website Leads</td>
<td>0</td>
</tr>
<tr>
<td>
<div class="checkbox checkbox-styled">
<label>
<input type="checkbox" class="datacontact" onchange="SelectContacts(this);" data-listid='7980' data-grpname='NewGroup1' />
</label>
</div>
</td>
<td>NewGroup1</td>
<td>0</td>
</tr>
<tr>
<td>
<div class="checkbox checkbox-styled">
<label>
<input type="checkbox" class="datacontact" onchange="SelectContacts(this);" data-listid='7996' data-grpname='My Group' />
</label>
</div>
</td>
<td>My Group</td>
<td>0</td>
</tr>
<tr>
<td>
<div class="checkbox checkbox-styled">
<label>
<input type="checkbox" class="datacontact" onchange="SelectContacts(this);" data-listid='9136' data-grpname='Email Functionality ' />
</label>
</div>
</td>
<td>Email Functionality </td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-flat btn-default-dark ink-reaction">OK</button>
<button type="button" data-dismiss="modal" class="btn btn-flat btn-default-dark ink-reaction">Cancel</button>
</div>
</div>
</div>
</div>
</div>
And through the below mentiond code, I have getting value of the checkbox called "Website Leads Seller"
package TestScripts;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.WebElement;
//import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;
public class EmailClient_VerifyEmail {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "C:/geckodriver/geckodriver-v0.21.0-win64/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.get("http://cp.iagentsolutions.com/login.aspx");
//enter email id
driver.findElement(By.cssSelector("#txtuserName")).sendKeys("abdul123");
//enter password
driver.findElement(By.cssSelector("#txtPassword")).sendKeys("admin123");
// click on login
driver.findElement(By.cssSelector("#LoginSnd")).click();
System.out.println("User Login Successfully from CP");
//hover on menu
//driver.findElement(By.xpath("html body.menubar-hoverable.header-fixed.menubar-visible form#form1 div#base div#menubar.menubar-inverse.animate div.nano.has-scrollbar div.nano-content div.menubar-scroll-panel ul#main-menu.gui-controls"))
Actions action = new Actions(driver);
//WebElement element =
action.moveToElement(driver.findElement(By.cssSelector(".menubar-foot-panel"))).perform();//("html body.menubar-hoverable.header-fixed.menubar-visible form#form1 div#base div#menubar.menubar-inverse.animate div.nano.has-scrollbar div.nano-content div.menubar-scroll-panel ul#main-menu.gui-controls")));
//click on Email Client menu for open sub-menus
driver.findElement(By.xpath("/html/body/form/div[3]/div[2]/div[2]/div[1]/div/ul/li[7]/a/span")).click();
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
// click on Create Email
driver.findElement(By.xpath("/html/body/form/div[3]/div[2]/div[2]/div[1]/div/ul/li[7]/ul/li[1]/a/span")).click();
//Enter draft name
driver.findElement(By.name("ctl00$body$txtDraftName")).sendKeys("Try to send without verify email");
//Click on Next button
driver.findElement(By.name("ctl00$body$btnStep1Next")).click();
//Email Settings
// Enter subject
driver.findElement(By.id("body_txtSubject")).sendKeys("Try to send without verify email");
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
//Click on Add / Edit to open Contact List
driver.findElement(By.linkText("Add / Edit")).click();
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
driver.findElements(By.xpath("//input[#type='checkbox' and #class='datacontact']")).forEach(elelemnt -> {
elelemnt.click();
});
}
}
But this code is only working for getting the check box title instead of clicking on the checkbox.
I have tested it and it is working properly :
using below code :
driver.findElements(By.xpath("//input[#type='checkbox' and #class='datacontact']")).forEach(element -> {
if (element.getAttribute("data-grpname").trim().equals("Website Leads Seller")) {
((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);
}
});

Unexpected Exception caught setting on class xxx: Error setting expression 'xxx' with value ['x', ] [duplicate]

I am trying to submit unknown number input from HTML Form to Action class and fetch the Input parameter information by using request Method(Used ServletActionContext) in the Action class.
But its throwing
Unexpected Exception caught setting 'xx' on 'class classname Error setting expression 'xx' with value ['yy', ]
Since input elements in the form are adding dynamically using JS, i am not in the position to have getters and setters in the Action class.
How to process the Action class without any exceptions?
JSP:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Team Activity Log</title>
<SCRIPT language="javascript">
function addRow(tableid)
{
var table = document.getElementById(tableid);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var element1 = document.createElement("select");
element1=document.getElementById("sele").cloneNode(true);
element1.type="select";
cell1.appendChild(element1);
var cell2=row.insertCell(1);
var element2 = document.createElement("input");
element2.type="text";
element2.setAttribute("placeholder","E.g:1234");
cell2.appendChild(element2);
var cell3=row.insertCell(2);
var element3 = document.createElement("input");
element3.type="text";
element3.setAttribute("placeholder","Brief your work");
cell3.appendChild(element3);
var cell4=row.insertCell(3);
var element4 = document.createElement("input");
element4.type="text";
element4.setAttribute("placeholder","MM min");
cell4.appendChild(element4);
var cell5=row.insertCell(4);
var element5 = document.createElement("img");
element5.src="close.png";
element5.setAttribute("id","delete");
element5.setAttribute("onclick","changeImage(this)");
cell5.appendChild(element5);
}
function changeImage(temp)
{
(temp.parentElement).parentElement.remove();
}
function convert(tableid,temp2)
{
var table=document.getElementById(tableid);
console.log(table.rows.length);
var hidelement=document.getElementById(temp2);
hidelement.setAttribute("value",table.rows.length-1);
for(var i=1;i<table.rows.length;i++)
{
var tt="tt"+i;
var rf="rf"+i;
var des="des"+i;
var eff="eff"+i;
console.log("executing function");
var elemen=table.rows[i].cells[0].querySelector("*");
elemen.setAttribute("name",tt);
elemen=table.rows[i].cells[1].querySelector("*");
elemen.setAttribute("name",rf);
elemen=table.rows[i].cells[2].querySelector("*");
elemen.setAttribute("name",des);
elemen=table.rows[i].cells[3].querySelector("*");
elemen.setAttribute("name",eff);
}
}
</script>
</head>
<body>
<INPUT type="button" value="Add Row" onclick="addRow('matrix')" />
<%# taglib uri="/struts-tags" prefix="s" %>
<s:url id="myActionUrl" action="timesheetprocess" />
<form action=<s:property value="%{myActionUrl}" />>
<input type="hidden" id="taskcount" value="5">
<table id="matrix">
<tr>
<th>Task Type</th>
<th>Reference ID</th>
<th>Description</th>
<th>Efforts</th>
<th></th>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr><tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
</table>
<INPUT type="button" value="Submit" onclick="convert('matrix','taskcount')" />
</form>
</body>
</html>
Action tag in struts.xml
<action name="timesheetprocess" class="com.App.Controller.Timesheet.Timeprocess"
method="execute">
<result name="success">Time.jsp</result>
</action>
My Action class:
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
public class Timeprocess {
public String execute() {
HttpServletRequest request = ServletActionContext.getRequest();
String tt="tt";
String rf="rf";
String des="des";
String eff="eff";
for(int i=0;i<Integer.parseInt(request.getParameter("taskcount"));i++)
{
System.out.println("Task Type :"+ request.getParameter(tt+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(rf+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(des+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(eff+String.valueOf(i)));
}
return "success";
}
}
You can control the process of parameters population by Struts2 via overriding interceptors in the action config.
<action name="timesheetprocess" class="com.App.Controller.Timesheet.Timeprocess"
method="execute">
<interceptor-ref name="defaultStack">
<param name="params.excludeParams">.*</param>
</interceptor-ref>
<result name="success">Time.jsp</result>
</action>
There you modify the excludeParams property of the params interceptor to exclude all parameters from processing via OGNL.
You should not get any exception in this way, but make sure you have configured struts.devMode=false
<constant name="struts.devMode" value="false" />
It should remove unnecessary warnings from the output. If you still get any warnings or exceptions in the log, then you should configure your logging framework to suppress those warnings or errors from the output.

Cannot add data into database for crud using servlet

<form action="addCustServlet" method="POST" name="frmAddUser">
<table>
<tr>
<td><h3 class="templatemo-gold">ID Number: </h3></td>
<td>
<input type="text" name="cust_id" size="12" value="<c:out value="${customer.cust_id}" />" /> <br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Name: </h3></td>
<td><input type="text" name="custName" size="50"
value="<c:out value="${customer.custName}" />" /> <br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Address: </h3></td>
<td><input type="text" name="custAdd" size="50"
value="<c:out value="${customer.custAdd}" />" /><br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Region: </h3></td>
<td><input type="text" name="custRegion" size="50"
value="<c:out value="${customer.custRegion}" />" /><br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Handphone No: </h3></td>
<td><input type="text" name="custHandphoneNo" size="50"
value="<c:out value="${customer.custHandphoneNo}" />" />><br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Phone No: </h3></td>
<td><input type="text" name="custPhoneNo" size="50"
value="<c:out value="${customer.custPhoneNo}" />" /><br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Email: </h3></td>
<td><input type="text" name="custEmail" size="50"
value="<c:out value="${customer.custEmail}" />" /><br/><br/></td>
</tr>
<tr>
<td> <input type="submit" name="submit" class="btn text-uppercase templatemo-btn templatemo-info-btn">Submit </td>
</tr>
</table>
</form>
Whenever I try to insert data using jsp form, it keeps executing nullPointerException as my cust_id is not auto generated or auto increment.
After I click addbutton, servlet sent to updateUser and data cannot be inserted.
Customer customer = new Customer();
customer.setCustName(request.getParameter("custName"));
customer.setCustAdd(request.getParameter("custAdd"));
customer.setCustRegion(request.getParameter("custRegion"));
customer.setCustHandphoneNo(request.getParameter("custHandphoneNo"));
customer.setCustPhoneNo(request.getParameter("custPhoneNo"));
customer.setCustEmail(request.getParameter("custEmail"));
String cust_id = request.getParameter("cust_id");
if(cust_id == null || cust_id.isEmpty())
{
dao.addUser(customer);
}
else
{
customer.setCust_id(cust_id);
dao.updateUser(customer);
}
RequestDispatcher view = request.getRequestDispatcher(LIST_USER);
request.setAttribute("customer", dao.getAllCustomer());
view.forward(request, response);
}

How to interact with table on webpage with Java?

I'm trying to make a program for work to automate a spreadsheet that we maintain. The information is on a third party website that we log in to and then scroll through a bunch of pages and then a table is there with all of the info in it. I used selenium webdriver to open internet explorer, log you in, then navigate you to the correct page but I don't know how to interact with the table. When I inspect element in Gooogle chrome, there is no ID or name showing up for the table or any of its cells. Thanks in advance guys.
Edit:
Here is the HTML Code. I put asterisks for sensitive info. The asterisked info is what I need to pull. I only posted the first quarter or so of the code because it's too many characters but the code just repeats for more rows.
<HTML>
<HEAD>
<TITLE>***************</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function to_SchedForm(theForm) {
var j = 0;
if (theForm.p_chkbox_cnt.value == 1)
{
if (theForm.p_part_chkbox.checked ){
++j;
}
}
else{
for (var i = 0; i < theForm.p_part_chkbox.length; i++ ) {
if (theForm.p_part_chkbox[i].checked ){
++j;
}
}
}
if (j == 0) {
alert("No Part Numbers Selected");
return false;
}
return true;
}
function to_MultiSchedForm(theForm) {
var j = 0;
var c = 0;
var k = 0;
for (var i = 0; i < theForm.p_part_chkbox.length; i++ ) {
if (theForm.p_part_chkbox[i].checked ){++k;
if (theForm.p_mode_chk[i].value != "CR"){
++j;
}
}
}
if (k == 0) {
alert("No Part Numbers Selected")
return false;
}
if (j != 0 && theForm.ACTION1.value == "multi_order") {
alert("The Multiple Schedule Update option is only available for Schedules that currently have a blank Last Commit value. Use the Individual Schedules Button to change a commitment Date.")
return false;
}
return true;
}
</SCRIPT>
</HEAD>
<BODY>
<TABLE BORDER="0" WIDTH="100%"
CELLSPACING="0" CELLPADDING="0">
<TR>
<TD WIDTH="100%", VALIGN="top"><IMG SRC="/apps/space/img/PPPS_NEW.jpg" ALT="GM Banner" NAME="PPPS1"></TD>
</TR>
<TR>
<TD width="50%"><HR></TD>
</TR>
</TABLE>
<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"
CELLPADDING="0">
<TR>
<TD WIDTH="100%", VALIGN="top", ALIGN="center"><IMG SRC="/apps/space/img/priority3.jpg" ALT="Priority Banner" NAME="Priority1"></TD>
</TR>
</TABLE>
<BR>
<CENTER>
<TABLE WIDTH="100%">
<TR>
<FORM ACTION="Schedule.PrioritySummary" METHOD="POST" NAME="to1_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="none">
<TD VALIGN="BOTTOM" ALIGN="LEFT"><FONT FACE="courierNew" SIZE="2"><B> Part #:</B><INPUT TYPE="text" NAME="p_pnum" SIZE="12" MAXLENGTH="12"></FONT><INPUT TYPE="submit" VALUE="GO"></TD>
</FORM>
<FORM ACTION="Schedule.PrioritySummary" METHOD="POST" NAME="to2_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="none">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<TD VALIGN="BOTTOM" ALIGN="LEFT"><FONT FACE="courierNew" SIZE="2"><B> Order #: </B><INPUT TYPE="text" NAME="p_onum" SIZE="12" MAXLENGTH="12"></FONT><INPUT TYPE="submit" VALUE="GO"></TD>
</FORM>
<FORM ACTION="Schedule.PrioritySummary" METHOD="POST" NAME="to3_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="none">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<TD VALIGN="BOTTOM" ALIGN="LEFT"><FONT FACE="courierNew" SIZE="2"><B><SELECT NAME="p_proc"><OPTION VALUE="0">< Select Processor ><OPTION VALUE="KXH">K.Hr 918040497243 <OPTION VALUE="SJF">S. Fox 586-484-0855 </SELECT></B></FONT><INPUT TYPE="submit" VALUE="GO"></TD>
</FORM>
</TR>
</TABLE>
</CENTER>
<HR>
<CENTER>
<FONT FACE="courierNew" SIZE="2">Mfg. DUNS: <B>178522926</B></FONT>
<FONT FACE="courierNew" SIZE="2"><B>KAUTEX INC</B></FONT>
<FONT FACE="courierNew" SIZE="2">Z-code: <B>BL62</B></FONT>
</CENTER>
<CENTER>
<TABLE WIDTH="100%" BORDER="2" BORDERCOLOR="#00008B">
<TR>
<TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="5%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">Select One or More</FONT></B></FONT></CENTER></TH><FORM ACTION="Schedule.PrioritySummary" METHOD="POST" NAME="to4_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="iv_group" VALUE="">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns_number" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="part_num">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<TH BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><INPUT TYPE="image" NAME="p_img" SRC="/apps/space/img/Part_Number_Button2.gif" border="0"></B></FONT></CENTER></TH></FORM>
<TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="21%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">Description</FONT></B></FONT></CENTER></TH><FORM ACTION="Schedule.PrioritySummary" METHOD="POST" NAME="to5_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="iv_group" VALUE="">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns_number" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="ordr_num">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<TH BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><INPUT TYPE="image" NAME="p_img" SRC="/apps/space/img/Order_Number_Button2.gif" border="0"></B></FONT></CENTER></TH></FORM>
<TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="7%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">Last Commit</FONT></B></FONT></CENTER></TH><FORM ACTION="Schedule.PrioritySummary" METHOD="POST" NAME="to6_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="iv_group" VALUE="">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns_number" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="none">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<TH BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><INPUT TYPE="image" NAME="p_img" SRC="/apps/space/img/Due_Now_Button2.gif" border="0"></B></FONT></CENTER></TH></FORM>
<TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="5%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">Due 11/03</FONT></B></FONT></CENTER></TH><TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="5%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">Due 11/10</FONT></B></FONT></CENTER></TH><TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="5%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">Due 11/17</FONT></B></FONT></CENTER></TH><TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="5%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">Due 11/24</FONT></B></FONT></CENTER></TH><TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="5%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">Future</FONT></B></FONT></CENTER></TH><TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="5%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">Total</FONT></B></FONT></CENTER></TH><TH VALIGN="CENTER" ALIGN="CENTER" WIDTH="5%" BGCOLOR="darkblue"><CENTER><FONT COLOR="WHITE" SIZE="-1"><B><FONT FACE="courierNew" SIZE="2">SNR</FONT></B></FONT></CENTER></TH></TR>
<FORM ACTION="Schedule.SchedForm" METHOD="POST" NAME="toSchedForm"onSubmit="if (this.ACTION1.value == 'single_order')
{
if (to_SchedForm(this))
{
return true
}
else
{
return false
}
}
else
{
if (to_MultiSchedForm(this))
{
document.toSchedForm.action="Schedule.multi_schedform";return true
}
else
{
return false
}
return false
}">
<INPUT TYPE="hidden" NAME="P_EMS_DIVISION" VALUE="M ">
<INPUT TYPE="hidden" NAME="P_DOC_PREFIX" VALUE="XQ">
<INPUT TYPE="hidden" NAME="P_DOC_NUMBER" VALUE="APHL ">
<INPUT TYPE="hidden" NAME="P_DOCUMENT_TYPE" VALUE="Q">
<INPUT TYPE="hidden" NAME="P_PART_DLS" VALUE="A">
<INPUT TYPE="hidden" NAME="P_PART_PLS" VALUE=" ">
<INPUT TYPE="hidden" NAME="P_PART_NUM" VALUE="23214821">
<INPUT TYPE="hidden" NAME="p_mode_chk" VALUE="CR">
<INPUT TYPE="hidden" NAME="p_chkbox_cnt" VALUE="1">
<TR>
<TD VALIGN="CENTER" ALIGN="CENTER"><B><INPUT TYPE="checkbox" NAME="p_part_chkbox" VALUE="1"></B></TD>
<TD VALIGN="CENTER"
ALIGN="RIGHT"><FONT FACE="CourierNew" SIZE="2"><B>******** </B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="LEFT"><FONT FACE="courierNew" SIZE="2">TANK ASM - FUEL </FONT></TD>
<TD><FONT FACE="CourierNew" SIZE="2">*******</FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>-</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><B><FONT COLOR="*****" FACE="courierNew" SIZE="2"></B><B>12</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>****</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>-</B></FONT></TD>
</TR>
<INPUT TYPE="hidden" NAME="P_EMS_DIVISION" VALUE="M ">
<INPUT TYPE="hidden" NAME="P_DOC_PREFIX" VALUE="XQ">
<INPUT TYPE="hidden" NAME="P_DOC_NUMBER" VALUE="APHL ">
<INPUT TYPE="hidden" NAME="P_DOCUMENT_TYPE" VALUE="Q">
<INPUT TYPE="hidden" NAME="P_PART_DLS" VALUE="A">
<INPUT TYPE="hidden" NAME="P_PART_PLS" VALUE=" ">
<INPUT TYPE="hidden" NAME="P_PART_NUM" VALUE="***********">
<INPUT TYPE="hidden" NAME="p_mode_chk" VALUE="CR">
<INPUT TYPE="hidden" NAME="p_chkbox_cnt" VALUE="2">
<TR>
<TD VALIGN="CENTER" ALIGN="CENTER"><B><INPUT TYPE="checkbox" NAME="p_part_chkbox" VALUE="2"></B></TD>
<TD VALIGN="CENTER"
ALIGN="RIGHT"><FONT FACE="CourierNew" SIZE="2"><B>******** </B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="LEFT"><FONT FACE="courierNew" SIZE="2">TANK ASM - FUEL </FONT></TD>
<TD><FONT FACE="CourierNew" SIZE="2">J1UJ3 -000</FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>-</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><B><FONT COLOR="FF0000" FACE="courierNew" SIZE="2"></B><B>*****</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>0</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>********</B></FONT></TD>
<TD VALIGN="CENTER"
ALIGN="CENTER"><FONT FACE="courierNew" SIZE="2"><B>-</B></FONT></TD>
Okay, so its useful to know that you can find any element by its element id, e.g. driver.findElement(By.id("table")). This will give you the first element of that type. However, you have multiple tables, so you'll need to find a way to get the right table.
There are different ways to do this, but they'll usually revolve around some individual characteristic of your target. In this case the obvious example for me is that it contains this:
<TR>
<TD WIDTH="100%", VALIGN="top", ALIGN="center"><IMG SRC="/apps/space/img/priority3.jpg" ALT="Priority Banner" NAME="Priority1"></TD>
</TR>
Though this means we're looking down into children levels (makes things a little more complicated). What we can do is look for that particular element and then find its parent table via xpath like in this xpath tutorial.
So, to find the image element we simply use:
WebElement imageElement = driver.findElement(By.name("Priority1"));
This gives us the image element.
To find the table containing said imageElement we then use:
WebElement tableElement = imageElement.findElement(By.xpath(//ancestor::table));
This should find the ancestor element that is a table containing the priority1 image.
I suggest you have a look at how x-path works. Its very useful, but sometimes it does require a little tinkering (especially if a web page changes).

Categories

Resources