I saw other questions referring to xpath 2.0, which apparently simplifies string expressions. I'm using Firefox 3.5.5 and selenium 1.0.1.
How can I check if my versions of Firefox and Selenium support it?
Does Selenium defer to Firefox's built-in Xpath implementation?
In that case, if I start using another (perhaps older) browser with selenium, will I run into problems by expecting xpath 2.0?
By default, selenium uses the "native" version of XPath that comes with the browser. You can make it use a version that comes with Selenium, written in JavaScript. This seems to implement XPath 1.0, based on glancing at the source.
I think there is a jQuery plugin that gives you support for XPath 2.0. So, theoretically, if you inject jQuery and the plugin into your browser, maybe you could call XPath 2.0 commands with a JavascriptExecutor. Really, its probably not necessary though, but might be fun to play with.
Currently no browsers support XPath 2.0. To allow the use of a version that comes with Selenium, written in JavaScript, as suggested by #paul-biggar, use the following command :
allowNativeXpath(false)
more informations here :
http://www.seleniumwiki.com/software-testing/selenium-ide-allownativexpath/
Related
I am using HtmlAgilityPack 1.6.2 within a .NET Core 2.0 Console application. HtmlWeb.Load function works fine but LoadFromBrowser function is not available. I got a compiler error. The testing code is copied from the tutorial page so it should be correct. Please advise how to use the API.
The LoadFromBrowser method requires the WinForm WebBrowser to work.
Since there is not WebBrowser in .NET Core 2.0, this method is not available.
This method could be available in the future by replacing the WebBrowser by an open source browser but there is currently no short-term plan for it.
EDIT: Answer comment
Is there still no solution for this?
I didn't try it, but some package support web browser for .NET Standard such as : https://www.nuget.org/packages/Selenium.WebDriver
So perhaps if you use this package to retrieve the HTML and use it with HAP, that will work.
I have the same prob, installed Selenium.WebDriver, but don't know how to use it with HAP to wait until JS is loaded.
We are using Jasper Report's xml datasource. To create some output, we would need the XPath distinct-values() function, as described. If I use it like described, Jasper Studio gives me an error:
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("distinct-values(/connections/message/type)")
Does anyone know how to use XPath functions in Jasper Reports, jrxml files?
distinct-values() is a function that is exclusive to XPath 2.0. Unfortunately, Jasper Reports only support XPath 1.0 (ironically, the forum post is about exactly the same thing).
The short answer is: no, there is no XPath 1.0 function that eliminates duplicate values from a set of nodes.
There might be ways around this problem, if you can show more of your input XML document.
EDIT: For the record, here is the answer the OP got from the Jasper Reports Forum:
Hi, I talked with JR Team in order to better clarify the topic. So currently the version supported is XPath version 1.0. This because JR relies on Xalan or Jaxen for XPath support. These thirdy-part libraries currently support version 1.0.
Looking at the Jaxen FAQ it seems to be a "strict" decision they made, focusing only on compatibility support: http://jaxen.codehaus.org/faq.html
Which version of XPath does jaxen support? Does jaxen support XPath 2?
jaxen supports XPath 1.0. It does not support XPath 2.0. XPath 2.0 is a very different spec with many things to recommend it and a few things not to like as well. However XPath 2.0 is not compatible with XPath 1.0. It is far from a simple upgrade from XPath 1.0. It has a very different data model, that might well require significant revisions to jaxen's internal data structures, and possibly a very different API as well.
The current release plan focuses exclusively on XPath 1.0 compatibility. Perhaps one day someone will make a branch or fork of jaxen that supports XPath 2. However, this would be a significant undertaking, and so far little interest in this has been shown.
Therefore for the moment we will stay with version 1.0 of XPath
I disagree with the "a few things not to like" about XPath 2.0, but it is a clear answer, at least.
Is there any plugin or software where i can check the functions of Xpath 2.0 ??
Currently i am using Xpath Checker (ff Plugin) which only supports Xpath 1.0.
There is an online XPath 2.0 tool called PathEnq that might suit.
The tool runs client-side by using the Saxon-CE XSLT 2.0 processor (a JavaScript application) as a 'host' and dynamically generating XSLT based on your expression. XPath variables and namespaces are supported.
I'm using online xpath tester xpather which works really nice.
Note: It's xpath 2.0 support is currently in beta.
Is xpath-locator plug-in for Firefox can help in locating the elements in selenium script.
Any limitation using this plug-in in script?
It's always better to create your own xpath using firebug, firepath (a firebug extension) , webdeveloper or any other tool. You will learn to create xpaths which are not brittle. :)
Your question is very generic. It is not possible to cover all or at least the most variants of dynamically generated HTML source code to find elements by just using Xpath or CSS selectors. You will need a more "intelligent" logic.
If you tell us what your exact task is, we may help you with a solution for your problem.
I wrote a firefox plugin using C++ and used the <EMBED> to load it to html.
In javascript I got the embedded plugin by using document.getElementByID,
but when I tried to call a plugin function, the function was undefined. Moreover,
plugins constructors did not run while loading the page.
The same html file and plugin seems to work on some computers, while it doesnt work on others.
Does anyone have an idea what might by wrong?
How can I debug such an issue?
Can you reproduce it on your computer at first? If not, then try to figure out what systems, browsers, architecture, versions, they are using.
I recall, there are many GECKOSDK's, and each one has a specific version it works for. https://developer.mozilla.org/en/gecko_sdk For example, different SDK's for Firefox 1.5-2.0, FireFox 3.0, Firefox 3.5, and Firefox 3.5
For different browers, make sure you are exposing the right DLL Exports, browsers can vary: http://git.webvm.net/?p=npsimple is a good starting point. You can use firebreath.googlecode.com too as an alternative.
My suggestion would be to use an object tag instead of <embed>. In my experience, doesn't seem to work as reliably.
If I had more information on how your plugin is structured (are you using XPCOM or npruntime?), I might be able to help more.