Nokogiri stopped searching for sub tags - ruby

I was writing my ruby (2.0) script which reads a web page & it was working fine. Then I installed ruby 2.2 and suddenly my nokogiri stopped searching sub tags but not all. It still finds some sub tag and some aren't just being found in the same script.
I reverted back to 1.9 but its still doing the same thing. Currently I have installed ruby 2.1.6. I am loading pages with Watir-webdriver and open-uri. The following page is being opened by open-uri.
For an example, here is my code:
htmlPage = '<html>
<head></head>
<body>
<table width="100%" border="1">
<tbody>
<tr valign="top">
<td width="38%" bgcolor="#EFEFEF">
<b>
<font size="4">NPL Listing History</font>
</b>
</td>
<td width="62%" bgcolor="#EFEFEF">
<b>
<font size="4">Dates</font>
</b>
</td>
</tr>
</tbody>
</table>
</body>
<html>'
page = Nokogiri::HTML(htmlPage)
puts page.css("table [border='1']")
This should get me the table with border 1 but I get nil/null.
Am I doing something wrong? Or something I am missing?
Thanks!

Your problem is the space. In CSS selectors whitespace is the descendant combinator, so table [border='1'] means "all descendants of a table that have a border attribute equal to 1. What you want is table[border='1'], which means "all table elements that have a border attribute equal to 1."

Related

ASP Classic VB error 800a01a8 object required

I am attempting to fix an issue on a company website. The page in question is http://www.srbc.com/SiteMap.asp. I am getting the following error when trying to call a global options file:
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/_Includes/Callout_Global.asp, line 40
And this is the line the error references in the /_Includes/Callout_Global.asp file:
rs_main.open "Select TeamID, FirstName + ' ' + LastName as FullName from team where Category = 'Attorney' and IsActive = '1' Order by OrderNum"
The code controls the dropdown box that should contain a listing of attorney names.
This code works just fine on other pages in the site (see for example http://www.srbc.com/Careers/Default.asp).
I am not a coder, just trying to cleanup this site a bit. It is pretty dated code, but any suggestions on what I could do to fix this would be appreciated.
The coding on the SiteMap.asp page around where this function is called looks like:
<td width="210" valign="top" class="hideforprint">
<!--#include virtual="/_Includes/Callout_Global.asp" -->
</td>
<td width="20"> </td>
</tr>
</table>
<table width="726" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25"></td>
</tr>
</table>
</td>
<td width="22" valign="top" background="/Images/CommonImages/rightborder.gif"> </td>
</tr>
</table>
<!--#include virtual="/_Includes/Footer.asp" -->
</body>
</html>
Thanks!
That error would suggest that you haven't created an object called rs_main. It looks like it should be a recordset object, so you earlier in your code you should have the line
Set rs_main = Server.CreateObject("ADODB.Recordset")
Could you post the first 40 lines of Callout_Global.asp, there might be other stuff missing?
I'm a dope!
I figured it out. At the top of the SiteMap.asp code, there was a function call missing. Once I added that back in, everything started working. I just noticed that was different from every other page that was working normally.
Now to tackle a search index issue.
Thanks!

CKEditor Removing attributes in closing tags

I have allowedcontent=true which is working and allowing me to have attributes in my opening tags; however, CKEdtior is still removing the closing tag attributes. I am using the editor to allow modification of simple Handlebars templates that use {{each}} and {{/each}}. The issue comes when using this with a table and wanting to repeat my rows.
For example, I have the following HTML entered into source:
<table>
<tr data-each={{each Person}}">
<td class="col-student-id">{{Identifier}}</td>
<td class="col-name">{{Name}}</td>
</tr data-each="{{/each}}">
</table>
When I click out of source, it removes the attribute on my closing tr tag.
Is there anyway to force CKEditor to not remove this attribute? If not, does anyone know of a way to allows me to use something like this:
<table>
{{each Person}}
<tr>
<td class="col-student-id">{{Identifier}}</td>
<td class="col-name">{{Name}}</td>
</tr>
{{/each}}
</table>
When I try the above example, it is reformatted to be:
<section>{{each Person}} {{/each}}
<table>
<tr>
<td class="col-student-id">{{Identifier}}</td>
<td class="col-name">{{Name}}</td>
</tr>
</table>
Your input source code is invalid - closing tags cannot have attributes in HTML, so CKEditor ignores them. Read more in CKEditor HTML Autocorrection Issue.

selenium webdriver xpath generation

I want to create an xpath for clicking on "run " (4th column) based on the first column value (xyz). the below xpath doesnt work. Can you suggest a better way of writing the xpath.
//table/tbody/tr/td[text()='xyz fix']/parent::tr/td[4]
<div id="main">
<table class="FixedLayout" width="1000px">
<tbody>
<tr></tr>
<tr>
<td class="RowHeight">
xyz
</td>
<td>xyz fix</td>
<td>1125</td>
<td>
Run
</td>
</tr>
<tr>
<td class="RowHeight">
abc
</td>
<td>abc fix</td>
<td>1125</td>
<td>
Run
</td>
</tr>
</tbody>
</table>
</div>
I don't see why your one didn't work. Please clarify what it means "doesn't work". NoSuchElementException? ElementNotVisibleException? Wrong XPath? Not clicking the link or what?
Meanwhile, try the following XPaths (but the issue could be your Selenium code instead of XPath):
Here I assume you want to the <a> link instead of <td>, because you mentioned you want to click it.
Use XPath predicate:
//*[#id='main']//table/tobdy/tr[td[text()='xyz']]/td[4]/a
Use XPath predicate with attribute selector to avoid using index.
//*[#id='main']//table/tobdy/tr[td[text()='xyz']]//a[contains(#href, 'Instance/Create')]
Use .. to get the parent
//*[#id='main']//table/tobdy/tr/td[text()='xyz']/../td[4]/a

How to use rowTemplate and detailTemplate together in KendoUI?

I having trouble using a rowtemplate with a detail grid.
Basically when I use them in combination, the rendering is messed up.
See this fiddle, http://jsfiddle.net/yzKqV/, to reproduce this error (uncomment the commented out line and run again to see the error).
How do I fix this?
I think the reason your rowTemplate is not working when you use detailTemplate is because it needs to have the tr and first td defined like a hierarchy grid. (http://jsfiddle.net/yzKqV/3/)
<script id="rowTemplate" type="text/x-kendo-tmpl">
<tr class="k-master-row">
<td class="k-hierarchy-cell"></td>
<td> #= FirstName # </td>
<td> #= LastName # </td>
</tr>
</script>

Firefox displays 3 columns in a table, IE8 only 2

Would love some help here... Firefox displays the last column in the table (an image they click on to edit their email address, it's a link), and IE8 displays nothing for the last column (doesn't even appear to display a column!) I've left out other rows in the table, but similar stuff happens.
Anyone know why?
<table class="profile-display">
<tr>
<td style="text-align: right; color: red;"> Email address: </td>
<td class="profile-content"> <?php echo("$evar"); ?> </td>
<td> <a href="profile_change.php?edit=13"
<img src="../images/writegreen.png" class="profile-edit" alt="Edit"
title="Edit Email Address"
border="0" />
</a>
</td>
</tr>
</table>
Your <a> tag is missing its >. That will cause a browser to not recognize the end of the tag until the first > it sees, which is the end of the img tag. Frankly, I'm surprised that Firefox shows the img.
Edit: Other common causes of this problem are missing quotes and misspelled tags.

Resources