I have a web page that I am trying to pull data elements from. I am trying to figure out how to loop the tags in the web page, contained within the specific "TABLE" tags shown.
Dim ProductionRpt = WebBrowser1.Document.GetElementById("ProductionReport").Children
For Each row As HtmlElement In ProductionRpt
MsgBox(row.InnerText)
Next row
The above code is what I am trying to do with the table rows, only the code above returns the innertext for the table html element, and not any of the tags contained within the table. Perhaps this is expected if you are only looking at the table element itself (which is indeed what I told it to do) and not any of the rows. How do I loop through all the tags so I can get access to the data I want? Is there another way besides using .GetElementsByTagName?
It depends on what you're expecting to find inside those rows... If you're sure to find 0 or 1 level of <a> tags you should simple create additional If statements and Loop to check using GetElementsByTagName like you said. Even if you had more tags to check for you could iterate through a list of "expected tags".
If you don't know how many nested elements inside each row you're going to find then you should probably create a recursive function and look for any child element (and its value) inside a row before continuing to the next one.
http://msdn.microsoft.com/en-us/library/81tad23s.aspx
Related
I am using webdriver to test our application that contain table where the user can change the order of columns in a table,and also can remove/add columns (This is beside new column added by developers).
What is the right way to find the column I need?
One way is to go over the table header to find the column I am looking for so I have the column index and than I can access the right cell.
Is there other way ?
What about put unique id/class name for every element in table ?
Thanks
You can do two things for this situation:
Get handle to table element, and then navigate accordingly to get the columns or rows. Once you have this, then you can do all operations on them like click() etc.
Other way is, see the pattern of their ids/css because, most of the table that I have deal with will be having ids like this:
grid_name_1
grid_name_2
grid_name_3
Then you can have do this way:
String baseLocator = "grid_name_" + clickedRowIndex;
driver.findElement(By.id(baseLocator)).click(); //for click operation
Lets say user wants to click on the 3rd row, then clickedRowIndex will be 3 which selects the 3rd table row.
How do I get the position for a field nested in multiple level of records:
select position(repeatedRec.rec1.field)
where repeatedRec is a repeated record, and rec1 is a non-repeated record? Assume that repeatedRec doesn't have any other leaves. I need to know what is repeatedRec position for the element in which rec1.field resides.
This doesn't seem to work, and all I get is 1 (as if the system is treating the field as a non repeated field).
have you tried
select position(repeatedRec.rec1.field) WHITHIN repeatedRec.rec1 as f1
https://developers.google.com/bigquery/docs/data#within
see this link for a small documentation on within
I am using datatable (v1.10.2 with jquery 1.9.2) because I like the out-of-the-box features (searching/sorting etc). However, now I want the ability to:
1) use animations (sliding) when showing/hiding a row
2) have the hidden row available in the DOM to change (ie, it would exist but have a display:none).
My current code to create the table looks like the following (where formatChild() returns html for a table):
if (row.child.isShown()){
row.child.hide();
tr.removeClass('shown');
} else {
row = row.child(formatChild());
row.show();
tr.addClass('shown');
}
I am using several services to change data in the child row's table via ajax and want to be able to change that data even when the row is hidden. I know I can create a map in memory and use the information in the stored map when I show the child row, but to me it is much cleaner to change the hidden row immediately.
I was hoping I could do a row()child(), modify the row, then call row()child().show() but the row isn't created in the DOM after the row.child().
Regarding the animation, I found an answer here but it involves changing the datatables code :(
I considered just using jquery to add a row to the datatable and hide it, but I couldn't find a good way to "attach" it to the primary row for sorting.
The plan I am currently leaning towards is to add a div to my primary table row that I will show/hide/update rather than using child rows at all.
What is the best practice for managing these hidden areas in a datatable (and showing them with animation)? ty
In case anyone else has the same question, I ended up using a DIV in the row rather than using DataTables' child row. When I add a new row to the datatable, the div is hidden then I hide and show (slideup/slidedown) on a click event. This gives me the nice animations, keeps the sorting simple, and let's me change information in the hidden row. Interestingly, the DIV contains a table and the text that is in that table when I create the new row is searchable; however, the text in the table that my ajax call adds/modifies is not searchable. I'm looking into how I want that to work (and may keep the div out of the search altogether if possible).
I am trying to use selenium to check that a table on the page has a particular string.
I am trying to use "Table Should Contain". Does this check all the pages of result or only the results displayed on the current page?
1) You can use isElementPresent() or isVisible() functions
2) You can get the css for the entire table and do a search for the particular string you're searching for.
Option 2 tends to be faster, but I don't know how the table on the page works, so the string might be in the css selector even though its not actually displayed on the page.
Is it possible to generated a "Print When Expression" that detects the last element in an XML datasource file?
Basically I have a report with a column break inserted after a sub-report in a detail band so I can clearly define new pages for the beginning of a new record. But it always leaves me with a blank last page. So I am hoping that I can prevent this if I have a print when condition that prevents the column break if it is the last record element in the XML datasource.
Is this even possible?
The problem is that you don't know it's the last element until after you look for the next element. I don't think there is a simple way.
In principle it should be fine to do something like this:
Create a super-report around the entire report. Run the same query in the super-report. Count the rows. Then pass the number of rows to the original report (which is now a subreport) and re-run the query again. Clearly, running the query twice is another drawback.
If the data source were SQL, then I would suggest modifying the SQL to return the number of rows as part of the result set. But for non-SQL data sources, you need some way of knowing the number of rows (well... some way of identifying the last row) before you reach the last row.
Many years late...
if you sure your datasource is a JRBeanCollectionDataSource, you could use:
$V{REPORT_COUNT} == ((net.sf.jasperreports.engine.data.JRBeanCollectionDataSource)ORIGINAL_DATA_SOURCE( )).getData().size()