Find the XPATH for a table of data - html

I'm trying to learn about scraping information from a website for iOS and I'm using a website of a local radio station to practice. I have tried by best to figure out the Xpath needed to present the information within the tags in a table. The HTML is as follows (there are many more table rows, this is just the first one).
EDIT
<form action="http://www.someurl.ie/index.php/news" method="post" name="adminForm" id="adminForm">
<table class="category">
<tbody>
<tr class="cat-list-row0" >
<td class="list-title">
<a href="/index.php/news/some-news-story-here">
some news story here</a>
</td>
</tr>
This is the path that I have come up with but it hasn't worked for me. Could anyone direct me as to what I'm doing wrong/missing with this?
#"//div[#class='cat-items']/form[#id=adminForm]/#action/table[#class='category']/tbody/tr[#class='cat-list-row']/td[#class='list-title']/a"])
<div class="cat-items">
If anyone could help or point me in the direction of help I would be very grateful. Thanks!

There are three problems in your XPath expression:
The <form/> id 'adminForm' is unquoted
The attribute #action is a path step in the middle of the expression
The <tr/> class 'cat-list-row0' is missing the zero.
The corrected expression:
#"//div[#class='cat-items']/form[#id='adminForm']/table[#class='category']/tbody/tr[#class='cat-list-row0']/td[#class='list-title']/a"

Related

How to add a hyperlink to a Spring Data object with thymeleaf

I have something like this:
<td th:text="${e.name}">My Event</td>
I need to add a hyperlink to e.name but I can't figure out how, and I think my google skills may be lacking as well since I can't find anything on how to do it.
Thanks for any help.
Just as in a normal HTML document you'll need to wrap an anchor element around what you want to link. For instance like this
<a th:href="#{http://www.thymeleaf/documentation.html}"><td th:text="${e.name}">My Event</td></a>
Other variants can be found by reading the Thymeleaf Standard URL Syntax
It should look like this:
<td>My Event</td>
You can use th: attributes on any html tag.
Here's an example declaring everything in the href and using an expression to modify the wrapped text:
<td><a th:href="#{${obj.website}}" th:text="${#strings.abbreviate(obj.website,50)}" /></td>
One declares the text and the href inside of the anchor tag.

selenium ide data structure tree expand

a few days from now I am trying to write a selenium ide test for a data structure tree. I stuck with expanding tree nodes, the main thing is that there is a lot of TreeExpandoIcons of the same class, no id, text, type and so on.
<tbody>
<tr>
<td title="Control + right arrow key to expand this row." aria-expanded="false" aria-readonly="true" role="gridcell" tabindex="-1" aria-describedby="RestartPageGrid-Id" colid="Id" class="gridxCell" style="width:auto;min-width:auto;max-width:auto;">
<div class="gridxTreeExpandoCell " style="padding-left: 16px;">
<div class="gridxTreeExpandoIcon " style="margin-left: 0px;">
<div class="gridxTreeExpandoInner">+</div></div>
<div class="gridxTreeExpandoContent gridxCellContent">1</div>
</div>
</td>
There is always only one difference between icons, near icon is gridxCellContent number . But It is only near and it is not clickable. Maybe you know some workaround or how to solve this problem? I would be very appreciated.
My selenium ide offers, to write like this:
<tr>
<td>click</td>
<td>css=div.gridxTreeExpandoIcon.</td>
<td></td>
</tr>
But this code isn't working.
There are few queries I have :
1. Have you tried removing the last (.) in the css selector ?
2. Also i see that
"gridxTreeExpandoIcon " class has a trailing space.
Are you aware of using contains in css selectors?
3. Have you tried using different location strategy ?
such as xpath, //div[contains(#class,'gridxTreeExpandoIcon')]

Extract information from web page throughExcel vba

I have the following html code
<tr>
<td class="fontblue" style="height: 17px">
Primary Industry Code
</td>
<td class="fontlightblue" style="height: 17px" colspan="4">
<span id="ucOrganisationDetail_lblVPrimarySector">
FMP CB:Miscellaneous Manufacturing
</span>
</td>
</tr>
I would like to extract the text FMP-CB Miscellaneous Manufacturing using getelementbyID option in vba. can anyone please help me
I tried using the below vba code but nothing is working
objIE.Document.getElementByID("ucOrganisationDetail_lblVPrimarySector").Value
Try the following:
objIE.Document.getElementByID("ucOrganisationDetail_lblVPrimarySector").innerHTML
You want .innerText as mentioned in comments I see.
.innerText
Sets or returns a String that represents the text between the start
and end tags of a specified object without any associated HTML.
expression.innerText
expression Required. An expression that returns one of the objects
in the Applies To list.
You could use
objIE.Document.getElementById("ucOrganisationDetail_lblVPrimarySector").innerText
or a CSS selector which says the same thing of:
objIE.Document.querySelector("#ucOrganisationDetail_lblVPrimarySector").innerText
The element is correctly selected as you can see with:

optimize angularjs search filter and trigger html tab even by clicking on link

I hope someone can help me with these two problems.
They are part of the same work but different from each other.
I am using angularjs to filter through a list that is quiete big (more than 1000 elements) but it's very slow. I was wondering if there's a way to optimize this.
Here's the code
<div class="test">
<table class="table table-hover" >
<tbody>
<tr ng-repeat="test in tests| filter:query">
<td>
<div id="delete">D<br />E<br />L<br /></div>
<div id="edit">E<br />D<br />I<br />T</div>
<p ng-show="test.id">ID:<b>{{test.id}}</b></p>
<span ng-repeat="name in test.names" ng-show="test.names">Company: <b>{{name}}</b></span>
<span ng-repeat="age in test.ages" ng-show="test.ages">Country: <b>{{age}}</b></span>
<span ng-repeat="course in test.courses" ng-show="test.courses">Found: <b>{{course}}</b></span>
<span id="output" ng-show="test.out1">Then: <b>{{test.out1}}{{test.out2}}{{test.out3}}{{test.out4}}</b></span>
</td>
</tr>
</tbody>
</table>
</div>
The second question is regarding "tabset" in html
I have 3 tabs and in one tab I have an edit link on each item, I want the third tab to come up when I click on the edit link of the first tab.
I searched online and understand that some js or jquery is needed but nothing has worked so far.
thank you in advance
If you are handling such a big set of data you should use a pagination system.
Also I won't attach the entire 1k object to the scope and and use a filter in the ng-repeat but instead add just a chunk of data like 50 to the scope and every time you change the page you would change the $scope.tests with the next/previous 50 items from your 1k.
One more point, if you are using a lot of interpolation {{}} but not each of them needs a separate watcher you should consider using angular's "bindonce".

How do I make a random folder load inside a div on load

Ok, first of all I'm sorry if my question appears unclear as I'm going to find it hard to explain. I don't know if you guys help with the coding at all but if you could set me off in the right direction that would be great.
Overview-
Basically similar to that of YouTube where on the side panel under "recommended >>" There is a single column with different rows. On each row there is a <div> element which contains a picture, title, who uploaded it and views. So these different parts so the title picture etc. are specific and link to that one video. I know the different videos that are recommended are based on numourous factors etc. But, anyway driving to the point here now-
Q- Is there a way of making the page load a random element or shall we say set for a video within a <div> tag?
I'll put up some code to demonstrate the basic layout:
<table>
<tr>
<td>
<div id="thumbnail">
<img src="thumbnail.png"
</div>
</td>
<td>
<div id="author">
<a> somebody </a>
</div>
</td>
... and so forth.
I have read up on how to make a random image come up upon load but is there a way of making a whole section or say a random style sheet come up on load? and each contain the different videos ( Just taking a stab in the dark here) or some sort of script?. Again I'm sorry if I'm sounded very vague or if I'm using the wrong terminology...