WatiN - Find HTML Table - watin

I´m trying to get the values of TDs inside a table using WatiN. The problem is that I´m not able to select a table by Id (because it´s missing) and three tables have the same CSS class:
table class='tablePpal' width='100%' cellspacing='2' cellpadding='1' border='0'
table class='tablePpal' width='100%' cellspacing='2' cellpadding='1' border='0'
table class='tablePpal' width='100%' cellspacing='2' cellpadding='1' border='0'
I need to select second table TDs. I tryed:
Table _table = browser.Table(Find.ByClass("tablePpal"));
Unfortunately that code does not return a collection of tables, only the first one found. How can I select the second table?
Thanks!

browser.Table(Find.ByClass("tablePpal") && Find.ByIndex(1))

Related

How to get rows from table with specific header using Xpath

I need to get all rows in an HTML table:
<table>
<thead>
<tr>
<th>Name</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dunkin Donuts</td><td>2 York Ave</td>
</tr>
</tbody>
</table>
Since there are many tables in the page I want to get the rows from this specific table.
Here is my Xpath:
table[tr/th/text()="Location"]//tr
I also tried:
table[tr/th[2]/text()="Location"]//tr
No elements are returned. Ideas on how I might get this to work?
Maybe your context node has no table children. You can fix this by globally selecting all table elements with //table. You also did not take the thead and tbody elements into account. Doing so results in the following XPath expression:
//table[thead/tr/th/text()="Location"]/tbody/tr

Tablesorter: Set initial filter-select value on load

I have a tablesorter table where a column uses the filter-select and filter-onlyAvail classes.
What I'm trying to do is pre-filter that column on one of the values in the drop-down select.
I have tried setting it in the data-placeholder attribute but that doesn't do the trick.
I've also tried the following:
$(document).ready(function(){
$.tablesorter.setFilters($("#table"),['','','','','','','','T'],true);
});
It correctly sets the filter in the select menu but doesn't actually RUN the filter.
Any ideas?
To initially set the filters, add the filter to a header "data-value" attribute (set by the filter_defaultAttrib widget option):
<table id="table">
<thead>
<tr>
<th>...</th>
...
<th data-value="T">...</th>
</thead>
<tbody>
...
</tbody>
</table>
You can see an example here in the Age column where <30 is initially set.

Access cell in table and click

I am writing a script to automate certain tasks. I am at a point where I have a table and hyperlinked name written in its second row, first column ([2][1]). I want to access that cell and click on it to go to intended page. Structure of the page looks like this:
<table id="listViewTable" class="listview" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-top: 0px;">
<tbody></tbody>
<tbody id="lvTred">
<tr id="1381137000000078119" class="tdout">
<td width="10" data-cid="dummy"></td>
<td class="lvCB" data-cid="dummy"></td>
<td>
<a id="listView_1381137000000078119" class="link" href="/crm/EntityInfo.do?id=1381137000000078119&module=Potentials&relCntId=1381137000000078117" data-params="{"relContactId":"1381137000000078117","module":"Potentials",…id":"1381137000000075541","recordNum":"1","lookback":"true"}" data-cid="detailView"></a>
</td>
I have successfully accessed table with id 'listviewTable' but not able to access cell with id 'listView_1381137000000078119' which is at location [2][1] in table. I did something like this:
cell = table.cell(:id, 'listView_1381137000000078119')
where table is actual table with mentioned id. Can anyone help?
Based on your HTML, there is no <td> tag with an id attribute of listView_1381137000000078119. However, there is an <a> tag with an id attribute of listView_1381137000000078119.
puts b.table.td(:id, 'listView_1381137000000078119').exists?
puts b.table.link(:id, 'listView_1381137000000078119').exists?
#=> false
#=> true

How to update BLOB column in Oracle which contains HTML code

I want to update a BLOB column in Oracle DB with HTML.
I am using Oracle Oracle Database 11g Release 11.2.0.3.0
The column contains HTML code which would be used in front end in JSP Servlets. The content of cell should be updated with below code
<table width="100%" border="0" cellspacing="0">
<tbody>
<tr>
<td height="130"> </td>
</tr>
<tr>
<td height="130">© 2013</td>
</tr>
</tbody>
</table>
The above code is formatted.The whole thing is single line.Now when I run a update query as below its showing the message
UPDATE TemplateTbl
SET TemplateConetent = (RAWTOHEX (UTL_RAW.cast_to_raw ('<table width="100%" border="0" cellspacing="0"><tbody><tr><td height="130"> </td></tr><tr><td height="130">© 2013</td></tr></tbody></table>')))
WHERE TemplateId = TL2600
Now oracle is asking for variable values because of © and as below
I have tried using underscore, Backslash and percentage in front of &copy and &nbsp. But nothing worked. How do I solve this issue?
1、sql plus or plsql command window
set define off;
UPDATE TemplateTbl
SET TemplateConetent = (RAWTOHEX (UTL_RAW.cast_to_raw ('<table width="100%" border="0" cellspacing="0"><tbody><tr><td height="130"> </td></tr><tr><td height="130">© 2013</td></tr></tbody></table>')))
WHERE TemplateId = TL2600
HTML ist plain text, use an (N)CLOB for that.

AngularJS: How to use ng-repeat on a data collection that is hierarchical

I am receiving a collection from server that is hierarchical. ie., I've a list of Study that contains Series. For example I get below object from server.
var studies = [ {studyDescription: 'Study1', series:[
{seriesDescription:'Series1'},
{seriesDescription:'Series2'}
]
}];
'series' is nested within a study.
I am using a HTML table to display this data. And I wanted to flatten the hierarchy while displaying. ie the table should look like:
Study Series
--------------------
Study1 Series1
Study1 Series2 ---> Study1 repeats for each series it contains
I use ng-repeat to iterate the the rows:
<tr ng-repeat="study in studies">
<td>{{studyDescription}}</td>
// HOW to repeat for each series ????
</tr>
How to display such hierarchical data using AngularJS ng-repeat directive? I tried using before , but that did not work. Basically I need multiple for loops to repeat the rows that many time. How to achieve this.
Thanks.
You can use multiple tbody to iterate on the series :
HTML :
<table border=1>
<thead>
<th>Studies</th>
<th>Series</th>
</thead>
<tbody ng-repeat="study in studies">
<tr ng-repeat="series in study.series">
<td>{{study.studyDescription}}</td>
<td>{{series.seriesDescription}}</td>
</tr>
</tbody>
</table>
Here's the JSFiddle :
http://jsfiddle.net/L3MWJ/1/
Tell me if it works for you, still I'm not sure if it will work on all browsers.
Did you try nested ng-repeat ? Try this :
<tr ng-repeat="study in studies">
<td>{{study.studyDescription}}</td>
<td>
<span ng-repeat="serie in study.series"></span>
<p> {{serie.seriesDescription}}</p>
</td>
</tr>

Resources