I want to show a table in my email list of objets in SendGrid. The table should look like following. There are dynamic number of rows in the table. How should I send the data from java code or design it in SendGrid?
<html>
<table style="width: 1px; height: 1px;" border="1">
<tbody>
<tr>
<td>heading1</td>
<td>heading2</td>
<td>heading3</td>
<td>heading4</td>
<td>heading5</td>
<td>heading6</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
</html>
Sendgrid doesn't provide a way to show table on the mail. I created an excel file and added it to the attachment.
Related
I have a table which can be found here: Ontario Gov Employee Directory and I'm trying to loop through the table to pull out the data, but struggling to find the xpath to be able to do so.
The table doesn't have an id, when I inspect the element I see:
<table title="results_list" border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="content" valign="top" align="right" width="50">1. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("32528")'>Aagaard, Lindsay</a>] [ Senior Policy Advisor ] [TREASURY BOARD SECRETARIAT]
<br>[DEPUTY PREMIER AND PRESIDENT OF THE TREASURY BOARD, Toronto]
<!-- [416-327-0948] -->
[416-327-0948] [
<a href="mailto:lindsay.aagaard#ontario.ca">
lindsay.aagaard#ontario.ca</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="content" valign="top" align="right" width="50">2. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("34417")'>Aalto, Margaret</a>] [ Probation Officer ] [CHILDREN AND YOUTH SERVICES]
<br>[THUNDER BAY, Thunder Bay]
<!-- [807-475-1310] -->
[807-475-1310] [
<a href="mailto:margaret.aalto#ontario.ca">
margaret.aalto#ontario.ca</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="content" valign="top" align="right" width="50">3. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("9187")'>Aarlaht, Andrew</a>] [ Business Analyst ] [COMMUNITY AND SOCIAL SERVICES]
<br>[HAMILTON, BUSINESS SERVICES UNIT, Hamilton]
<!-- [905-521-7335] -->
[905-521-7335] [
<a href="mailto:andrew.aarlaht#ontario.ca">
andrew.aarlaht#ontario.ca</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="content" valign="top" align="right" width="50">4. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("9187")'>Aarlaht, Andrew</a>] [ Business Analyst ] [CHILDREN AND YOUTH SERVICES]
<br>[HAMILTON, BUSINESS SERVICES UNIT, Hamilton]
<!-- [905-521-7335] -->
[905-521-7335] [
<a href="mailto:andrew.aarlaht#ontario.ca">
andrew.aarlaht#ontario.ca</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="content" valign="top" align="right" width="50">5. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("19146")'>Aarons, Drew</a>] [ Messenger ] [LEGISLATIVE OFFICES]
<br>[PARLIAMENTARY PROTOCOL, Toronto]
<!-- [416-325-7455] -->
[416-325-7455] [
<a href="mailto:daarons#ola.org">
daarons#ola.org</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="content" valign="top" align="right" width="50">6. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("113729")'>Aaswaakshin, Neegann</a>] [ Articling Student ] [ABORIGINAL AFFAIRS]
<br>[LEGAL SERVICES, Toronto]
<!-- [416-212-2271] -->
[416-212-2271] [
<a href="mailto:Neegann.Aaswaakshin#ontario.ca">
Neegann.Aaswaakshin#ontario.ca</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="content" valign="top" align="right" width="50">7. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("32196")'>Abad, Lilian</a>] [ Executive Assistant ] [TRANSPORTATION]
<br>[GO TRANSIT, Toronto]
<!-- [416-202-5506] -->
[416-202-5506] [
<a href="mailto:lilian.abad#gotransit.com">
lilian.abad#gotransit.com</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="content" valign="top" align="right" width="50">8. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("114240")'>Abadesso, Jennifer</a>] [ Employment Program Consultant (Acting) ] [TRAINING, COLLEGES AND UNIVERSITIES]
<br>[FOUNDATION SKILLS, Toronto]
<!-- [416-327-2065] -->
[416-327-2065] [
<a href="mailto:jennifer.abadesso#ontario.ca">
jennifer.abadesso#ontario.ca</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="content" valign="top" align="right" width="50">9. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("104293")'>Abakunzi, Louis</a>] [ Customer Service Representative (Bilingual) ] [GOVERNMENT AND CONSUMER SERVICES]
<br>[SERVICEONTARIO CONTACT CENTRE - NORTH YORK, Toronto]
<!-- [416-235-2999] -->
[416-235-2999] [
<a href="mailto:Louis.K.Abakunzi#ontario.ca">
Louis.K.Abakunzi#ontario.ca</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="content" valign="top" align="right" width="50">10. </td>
<td class="content">[<a class="results" href='javascript:showEmployeeDetail("19309")'>Aban, Edencio</a>] [ Audit Supervisor ] [ATTORNEY GENERAL]
<br>[AUDIT AND COMPLIANCE, Toronto]
<!-- [416-326-6295] -->
[416-326-6295] [
<a href="mailto:edencio.aban#agco.ca">
edencio.aban#agco.ca</a>]
</td>
</tr>
<tr>
<td> </td>
</tr>
</tbody>
</table>
How can I loop through the data in these rows?
It's a table within a table and then has some pretty standard formatting. What challenge are you having?
The table doesn't have an id, when I inspect the element I see:
It has other attributes you can use, like the title. Use the xpath //table[#title="results_list"]/tbody/tr/td to find each data element from the innermost table. Or remove the last /td from the xpath to get each row. After that, find each td element under it and use its text.
Note: The innermost table has 1st column with serial number and 2nd column with the actual data. I recommend getting each td and then using the 'innerHTML' attribute or elem.text. After that, use a regular exppresion to extract the different parts.
>>> all_tdata = driver.find_elements_by_xpath('//table[#title="results_list"]/tbody/tr/td')
>>> for td in all_tdata:
... print td.get_attribute('innerHTML') # save this in var and regex it
... # or
... data = td.text
I am coding in Java using Selenium Webdriver. I am unable to find the LINK Text "License Manager" in the page. When I tried switching to frame called "text". Selenium was unable to locate the frame named "text" please help.
This is my code:
d.switchTo().frame("enterpriseStatus");
d.findElement(By.id("bannerSettingsButton")).click();//settings button
d.manage().timeouts().pageLoadTimeout(15000, TimeUnit.SECONDS);
d.switchTo().window("name=text");//This is where something goes wrong
d.findElement(By.linkText("License Manager")).click();
This is the frame source:
<body>
<div class="tablecontentarea-div" style="width: 90%;">
<table class="tabletitlebar">
<tr>
<td>
<span class="titlepage">Settings</span>
</td>
</tr>
</table>
<div class="tablecontentpanel" style="padding-top: 15px;">
<table style="width:100%" summary="">
<tr>
<td style="width:50%; padding-right:7px; vertical-align: top;">
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/servers_32x32.png"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Device Management</div>
<div>
Add, manage, configure and delete devices.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Getting Started</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">All Devices</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Manage Agent Assignments</td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Policies</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Device Groups</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">NetApp Operations Manager</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Virtualization (Assign ESX Hosts)</td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Server Setup: Arrays</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Server Setup: Databases</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/alerting_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Rules & Alerting</div>
<div>
Setup rules that can perform a variety of actions, including running scripts.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">All Rules</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Threshold Rules</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Windows Event Log Rules</td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Asset Change Rules</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Scheduled Rules</td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Server Setup: Real Time</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Scripts</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/file_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Files</div>
<div>
Configure file analysis, file rules, assign shares to agents.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">File Analysis Rules</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Directory Analysis Rules</td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">File Type Groups</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Assign Remote Shares</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Assign Local Shares</td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Server Setup: File Analysis</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">Discover VM Targets</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">File Repository</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/user_accounts_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Users</div>
<div>
Add, edit, and remove user accounts.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Manage Users</td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Server Setup: User Authentication</td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td style="width:50%; padding-left:8px; vertical-align: top;">
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/server_profiler_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Storage Manager Server</div>
<div>
Configure and view information about your server.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Server Setup: All</td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top">About</td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Server Setup: E-mail</td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Data Retention</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/web_update_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Updates & Upgrades</div>
<div>
Upload new modules and upgrade your agents and pollers.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Upload Modules</td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Upgrade Agents</td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/reports_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">GUI & Reporter</div>
<div>
Configure GUI and Reporting behavior.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Server Setup: Reporter</td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Server Setup: GUI</td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/license_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">License Summary</div>
<div>
View your license type and number of storage modifiers.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">License Manager</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/Icon.Thwack.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">thwack Community</div>
<div>
Import shared application templates posted on thwack, a community site for Solarwinds users. thwack features helpful devices, tips and downloads from over 20,000 network engineers.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top">Storage thwack Forum</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</body>
To switch to window you have to use WindowsHandle.
You may try using below function provided that you are handeling windows with different titles.
private String mainWindowsHandle; // Stores current window handle
public static boolean swithToWindow(WebDriver driver,String title){
mainWindowsHandle = driver.getWindowHandle();
Set<String> handles = driver.getWindowHandles(); // Gets all the available windows
for(String handle : handles)
{
driver.switchTo().window(handle); // switching back to each window in loop
if(driver.getTitle().equals(title)) // Compare title and if title matches stop loop and return true
return true; // We switched to window, so stop the loop and come out of funcation with positive response
}
driver.switchTo().window(mainWindowsHandle); // Switch back to original window handle
return false; // Return false as failed to find window with given title.
}
So I'm pretty new to Selenium and I'm writing my first program with it. I'm trying to click a radio button that is on a table row. Here is the html code for the row.
<tbody>
<tr id="headerrow">
<td></td>
<td align="center">Name</td>
<td align="left">Account</td>
<td align="center">Status</td>
<td></td>
<td align="center">CW</td>
<td></td>
<td align="center">Last Hit</td>
<td></td>
<td align="right">IP</td>
</tr>
<tr>
<td height="1" bgcolor="#000000" colspan="10"></td>
</tr>
<tr>
<td height="10" colspan="10"></td>
</tr>
<tr id="userrow_1">
<td><input type="radio" name="id" value="1764" onclick="set_it('1');"></td>
<td>John Doe</td>
<td>jdoe</td>
<td align="center" bgcolor="#CCFFCC">Active</td>
<td> </td><td align="center" bgcolor="ccffcc">Yes</td><td> </td><td align="center" nowrap="">Offline - 12/12/12</td><td> </td><td align="right">192.168.1.1</td></tr>
</tbody>
I need to be able to click the button with only the value variable. Thanks for any help.
How about this:
driver.findElement(By.cssSelector("input[name='id'")).click();
This will click the radio button. input[name='id'] is the css selector, that will find your element. And click() method will click on it.
Im stucked in java based selenium usage, i like to click on input box (within table )by another cell text value
Here is my HTML code:
<DIV class=>
<P class=></P>
<UL></UL>
<FORM id="" onsubmit="" method=post name="" action="">
<TABLE width="100%">
<TBODY>
<TR>
<TD class=></TD></TR></TBODY></TABLE>
<TABLE>
<TBODY>
<TR>
<TD class=></TD></TR>
<TR>
<TD>
<TABLE class="" width="70%">
<TBODY>
<TR class="">
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR class="">
<TD><INPUT class="" onclick="" CHECKED type=checkbox><INPUT id= value=true type=hidden name=""> </TD>
<TD></TD>
<TD></TD>
<TD></TD></TR></TBODY></TABLE></TD>
<TR>
<TD><INPUT id="" class= onclick='' value="" type=button name=></TD></TR></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=""></TD></TR>
<TR>
<TD>
<TABLE class=foo width="100%">
<TBODY>
<TR class=foo-header>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR class="foo-odd">
<TD><INPUT onclick="" value="0" type="radio" name=""> </TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR class="foo-even">
<TD rowSpan="3"><INPUT onclick="" value="1" CHECKED type="radio" name=""> </TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD></TD>
<TD rowSpan="3"><INPUT id="" class="" value="" type="" name=""></TD></TR>
<TR class="foo-even">
<TD></TD></TR>
<TR class="foo">
<TD>CCC</TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><INPUT class="" onclick="" type=checkbox><INPUT id="" value="false" type="hidden" name=""> </TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=""></TD></TR>
<TR>
<TD>
<TABLE class="foo" width="100%">
<TBODY>
<TR class="foo-header">
<TD></TD>
<TD><BR><INPUT id="" class="" onclick="" value="" type="button" name=""></TD>
<TD colSpan="3"></TD>
<TD></TD></TR>
<TR class="foo-odd">
<TD><INPUT value="0" type="radio" name=""> </TD>
<TD></TD>
<TD></TD>
<TD colSpan="2"></TD>
<TD><SELECT class="" name=""> <OPTION value="0"></OPTION> <OPTION selected value="1"></OPTION></SELECT> </TD></TR>
<TR class="foo-even">
<TD rowSpan="2"><INPUT value="1" type="radio" name=""> </TD>
<TD rowSpan="2"></TD>
<TD rowSpan="2"></TD>
<TD></TD>
<TD></TD>
<TD rowSpan="2"><SELECT class="" name=""> <OPTION value="0"></OPTION> <OPTION selected value="1"></OPTION></SELECT> </TD></TR>
<TR class="foo">
<TD>CCC</TD>
<TD></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
</DIV>
I like to click on the second CCC text row related input,(not by only clicking name or xpath) im tried with followings:
driver.findElement(By.xpath(".//td[contains(text(),'CCC')]/preceding-sibling::td")).click();
Code above working in a *very similar html only contains CCC one time (tested with another HTML code )
WebElement services = driver.findElement(By.xpath(".//*[#id='installationAddressForm']/table[4]/tbody/tr[2]/td/table/tbody/tr[4]/td[1][contains(text(),'CCC')]"));
String contents = services.getText();
System.out.println(contents);
Code above able to find text but when combined with the top code(/preceding-sibling::td) it cannot find the input
Please help.Thanks in advance
The expression td[1][contains(text(),'CCC')] selects the first td and tests whether its text contains CCC.
Replace it with td[contains(text(),'CCC')][1].
I'd like to know if there's any way to send data to the server for the selected rows using the checkboxes I've put on those rows? I mean , how can I send only the data of those selected rows to the server?
Here's the html code I use:
<table>
<thead>
<tr class="tableheader">
<td width="10%"></td>
<td width="30%">Vehicle</td>
<td width="40%">Driver</td>
<td width="10%">Mileage</td>
</tr>
</thead>
<tbody>
<c:forEach items="${list}" var="item">
<tr>
<td align="center">
<input type="checkbox" name="selectedItems"
value="c:out value="${item.numberPlate}"/>"/>
</td>
<td align="left"><c:out value="${item.numberPlate}"/></td>
<td align="left"><c:out value="${item.driver.fullName}" /></td>
<td align="left"><input type="text" name="mileage" value="" /></td>
</tr>
</c:forEach>
</tbody>
</table>
I really hope you can give some guidance on this.
Thanks in beforehand.
When handling the request use request.getParameterValues("selectedItems"). And I don't think it's needed to add [] to names