I am trying to create a cucumber stage definition in Groove which is an XML document (a solar search result) compulsory 'url. Returns the status of this node on the basis of the tag's value and in the list of results.
This is my scenario: Looking at
This is my scenario: When I check for "Pace", then I should show this link in the results: "/ 7292 / Pre-trek -OG-instant "Then I will see the status of this URL:" / 7292 / PRES-WORK-OG-INTERTECH "
This is my definition:
Then (~ ^ ^ I should see this link in the results: "([^"] *) "$ ') {string tekst -> assertThat (browser.getPageSource (), containsString (tekst)}} ~ '^ I will see the status of this url: "([^" * *] "$') {string t Est -> pageSource = browser.getPageSource () // the position of relevant search result DEF xpathString = "print (parent / parent / parent / parent / :: * / preceding-bro :: *) "// +1 Builder = DocumentBuilderFactory.newInstance () .documentation_documentation )) Expr = XPathFactory.NewInstance () newXPath () compiling (xpathString) posisjon = expr.evaluate (doc) println "The result of this result is:". + Posisjon.toString () println xpathString}
Both tests return a green cueq, so I know that the string gets in XML. Here is an example of XML results which I am evaluating:
& Lt; Int name = "q time" & gt; 75 & lt; / Int> & Lt; Lst name = "params" & gt; & Lt; Str name = "indent" & gt; True & lt; / Str & gt; & Lt; Str name = "q" & gt; Price & lt; / Str & gt; & Lt; Str name = "wt" & gt; Xml & lt; / Str & gt; & Lt; / Lst> & Lt; / Lst> & Lt; Name of the result = "response" numFound = "306" start = "0" & gt; & Lt; Doc & gt; & Lt; Str name = "url" & gt; / Nasjonalregnskap / nokkeltall / priser-og-prisindekser & lt; / Str & gt; & Lt; Str name = "id" & gt; 3730 & lt; / Str & gt; & Lt; Str name = "titel" & gt; Praiser Og Precinctiser & lt; / Str & gt; & Lt; Str name = "innholdstype" & gt; Nokkeltallsside & lt; / Str & gt; & Lt; Date name = "publiseringsdato" & gt; 2010-11-23T11: 35: 00Z & lt; / Date & gt; & Lt; Str name = "hovedemner" & gt; Nasonolargenscope & lt; / Str & gt; & Lt; Str name = "sprak" & gt; No & lt; / Str & gt; & Lt; Str name = "Rome" & gt; Statistic & lt; / Str & gt; & Lt; / Doc & gt; & Lt; Doc & gt; & Lt; Str name = "url" & gt; 7292 / Pri-Tharak-OG-Intake & lt; / Str & gt; & Lt; Str name = "id" & gt; 7292 & lt; / Str & gt; & Lt; Str name = "titel" & gt; Price, scroll and intermediate & lt; / Str & gt; & Lt; Str name = "innholdstype" & gt; Publication & lt; / Str & gt; & Lt; Date name = "publiseringsdato" & gt; 2002-06-13T10: 00: 00Z & lt; / Date & gt; & Lt; Str name = "hovedemner" & gt; Baffling & lt; / Str & gt; & Lt; Str name = "sprak" & gt; No & lt; / Str & gt; & Lt; Str name = "Rome" & gt; Statistic & lt; / Str & gt; & Lt; / Doc & gt; & Lt; / Results & gt; & Lt; / Reaction & gt;
When I run this test (we are using Maven to create and run, I have limited debugging options) I get this output from two printline commands: < / P> <> The result of this result is: 0 computation (/ response / result / doc / str / parent: * / predecessor-bhai :: [= '/ 7292 / Panchayati Raj institutions- forbruk -OG-inntekt '.] *)
However, when I have the exact same XML document in this Exhaust query in Altova XMLspy Evaluation do, I get the desired result!
Apparently I do not have enough reputation for posting images (sorry, sorry ...), here is a link to a screenshot
then the question I do not understand Can the Java XPathFactory evaluate the Expressway differently from other interpreters? Have I made a mistake or an error in my implementation? The answer hides me :)
It finally understood that I was probably implementing XPathFactory. Evaluate one incorrectly. Anyway, I ended up using Gpath instead, this is the code I used to return the right result, if someone comes with a similar request in the future:
/ P>
string pageSource = browser.getPageSource () def stream = new XmlSlurper (). ParseText (pageSource) list test = stream.depthFirst (). FindAll {it. @name == "URL"} DEF status = test.findIndexOf {It.toString (). (Tekst) + 1 println pos
tell the future I say hi;)