What standard does JMeter use for HTML Assertion? - html

I added an HTML Assertion to my JMeter test. It returned many errors and warnings for the html page. I copied and pasted the same html code into the w3 validator and it returned much less warnings and errors. The w3 validator was set to HTML5 and HTML 4.1 Strict on separate occasions. I thought I would see the exact same errors / warnings in both instances.
I am not concerned about trying to figure out the exact differences. I do not care much about that. Both JMeter and the w3 validator are helping me clean up the code. That is fine.
What I am wondering is what JMeter uses as its standard for the HTML Assertion? Basically, what is it using to compare against when it points out the errors / warnings.
I also saw JTidy in JMeter. I looked up JTidy which is just a java port of HTML Tidy. But, I do not know what HTML Tidy uses as a standard.
Thanks in advance.

As per HTMLAssertion class JavaDoc
Assertion to validate the response of a Sample with Tidy.
If you want more flexibility - try using Beanshell Assertion instead

Related

How to convert HTML to JSP in Spring Boot

I've started creating some type of project for college and it's going pretty well, but after few steps I've found out that we need to do it in JSP, so in order not to lose too much points on little thing, I have tried to change HTML extensions to JSP, but without success. My pages has errors and I got this response on one of them:
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [user_form], template might not exist or might not be accessible by any of the configured Template Resolvers
Is there any way of painless conversion from HTML to JSP and what needs to be done?
I've tried to convert code from HTML to JSP.

Return only one element from a website using XPath or similar call?

I feel that I do not understand XPath as well as I should. I have a java-based webdriver that opens a webpage, returns one element, and then continues. I would like to speed this up and only open the webpage already pointing to the element. Is this possible?
For example, I open up the website at www.example.com and return element wherein the xpath=/html/body/div[3]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[3] .
I want to do that in one step.
I want to just be able to query
www.example.com/html/body/div[3]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[3]
How would I go about implementing something like this in my program? Would it even be faster?
Thank you in advance.
I take it from your question that you want to start a WebDriver and have it already pointed to www.example.com, so that you can just do you query in one step without first going to the page.
The answer is, you can't. You have to settle for two steps:
// Go to page
driver.get("http://www.example.com");
// Find element
driver.findElement(By.xpath("/html/body/div[3]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[3]"));
You can't just query a Web Page for an element without actually going to the page first and loading it in your browser. So no, you can't skip a step like you want to, to save time and speed up your application.
XPath, the XML Path Language, is a query language for selecting nodes
from an XML document.
With XPath you can't make HTTP requests and get HTTP responses, it is just a language to select XML nodes from an XML document.
I think these answers may need a little bit of an update, though, I want to note, that my answer is going to be purley XPath related. I have no knowledge about Java WebDrivers.
You can't do this with XPath 1.0. But you can do this with XPath, starting from version 2.0 (XPath and XQuery Functions and Operators 3.1 is the official documentation of the XPath functions for XPath 3,1, which, at this writing, is the current implementation. You can also find a, much more accessible, reference here.). The function, to do so is:
fn:doc($uri as xs:string?) as document-node()?
which would return the document as XML document node. So, your above query would be named:
doc("www.example.com")/html/body/div[3]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[3]
However, this does not result in an XML fragment being produced. Your client still would download the full HTML document and then, locally, extract the requested path.
To query an explicit XPath from a remote XML resource would require a few steps:
a change in the URI format specification [RFC 3986], that introduces an escape character, that marks an XPath expression within the URI. A single character, that tells the URI receiver: "all text after this character is an XPath expression". There was an interesting article regarding this, "Can a URL contain an XPath?", by Rick Jelliffe of Schematron fame on O'Reilly, but O'Reilly seems to have killed off those articles, the old links lead to their main landing page.
web servers, that could evaluate this URI and serve back the requested XML fragment (instead the whole document). This also would mean, that in your case, the fn:doc() function would not be needed (and the wrong tool for the job anyway, since, as stated, it always returns the full document).
last, but not least, a client, that can deal with XML fragments.
Sadly, these developments have been abandoned with the introduction of HTML5.

Debugging 'Error loading stylesheet: XPath parse failure: Name or Nodetype test expected:'

I am using an XSLT style sheet to convert an EAD xml file to an html finding aid on the web (pretty standard practice).
However, I have been wanting to preview it in Firefox by referencing the stylesheet at the top of the XML file and opening the XML file with the browser. This is working with a different stylesheet, but with the Stylesheet I want to use, I only get the error:
Error loading stylesheet: XPath parse failure: Name or Nodetype test expected:
It would be really great if I could get more specific error logging so it can tell me where in the XSLT file it is expecting Name or Nodetype test but it does not.
When I open the stylesheet and xml file in Oxygen XML Editor and run the transformation, I get the proper HTML document as a result, so I don't know how to debug it and figure out why it's not rendering from the XML file with the stylesheet referenced. I would prefer it this way because it works better with our workflow to just upload XML files to the same directory on the webserver as the stylesheet (than for me to have to transform the XML file and upload the HTML file to the server...Licenses for Oxygen editor aren't cheap, you know).
Is there anyway to force more details on why this is failing in the browser?
Oxygen allows you to develop XSLT stylesheets of the versions 1.0, 2.0 and 3.0. The XSLT processors in current browsers however are all XSLT 1.0 processors. Thus if you want to use Oxygen to develop stylesheets to be deployed in browsers then make sure you author XSLT version 1.0 stylesheets and configure Oxygen to use Saxon 6.5 or Xalan, both XSLT 1.0 processors, to run and test your code.
I suspect you use Oxygen with Saxon 9, an XSLT 2.0 processor and thus you run into errors in browsers if you have used any XSLT/XPath 2.0 only constructs in your code.
For instance in XSLT/XPath 2.0 you can write /root/foo/bar/tokenize(., '\|') where the last step in the path expression is a function call; in XSLT/XPath 1.0 this would give an error.
However Saxonica has brought XSLT 2.0 to browsers as Saxon-CE, an open source project that resulted from cross-compiling Saxon 9 HE to Javascript. That might be an option, see http://saxonica.com/ce/index.xml.
The error reporting from in-browser XSLT 1.0 implementations is typically very poor; if I were you I'd first check the stylesheet with a 1.0 implementation that provides good error messages (say, xsltproc and Saxon 6.5), and then (if the browsers persist in raising errors) by using the usual needle-in-a-haystack kinds of techniques to try to figure out where the problem is arising. If you can figure out where the problem is arising, but not why, then asking on Stack Overflow, or on the xsl-list at Mulberry Technologies will be the logical next step.

SCHEME: how to input html and output it as html source?

I am trying to write a simple web app in scheme and I am using Drscheme for the job. I am wondering if there is a way to input html code into a form which then outputs it in html format (into source)? Is there a library that does the job? Everytime I input something it turns out as a string, I need it to be read as html. Can someone help me? Thanks in advance!
If you want to use HTML template files, then look at the templates in the web server manual. Also, in case you're not familiar with the web server, then see the web server guide for a good introduction.

Make html validation part of build cycle

Currently when I build my site I have to manually open validate it at the 3wbc site (means when opera pops up, press ctr+alt+shft+u) for every page.
Is it possible to automatically validate every page whenever I build my pages?
P.s.: This page doesn't validate ;)
You can download and install your own copy of the validator - http://validator.w3.org/source/ - and invoke it locally instead of trekking out to w3.org for each page. Still, this requires piggybacking over a web server through plain HTTP or the API. For a simpler solution you may prefer to download the SP library - http://www.jclark.com/sp/index.htm or http://openjade.sourceforge.net/ - on which the W3 validator is based, then invoke the command 'nsgmls' from the command line.
There are of course also many desktop HTML validators that can process a batch of HTML pages at once, which may not be automated, but would certainly be much easier than manually checking each page. For example http://arealvalidator.com/ (Windows), http://www.webthing.com/software/validator-lite/install.html (Unix).
Might not be best choice for you but there's an Ant task for this: XmlValidate.
If you've got the HTML files in source control like SVN or Git, you can use a pre-commit hook script to run client-side validators on them. Or if you're feeling adventurous, you could use that method to ping another script on the server that validates the live pages...