Forum Discussion

brigadir's avatar
brigadir
Occasional Contributor
14 years ago

Cannot run Xpath in http request responses having <!DOCTYPE>

I've got problem running "http request" step with testrunner under Centos (linux) but same step passes on Windows system.


Under windows "Xpath" assertions work but under Centos they always fail. Seems that if webserver response contains DOCTYPE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
...


Failing Xpath assertion is
not(//input[@name='j_username'])
. Btw "contains" assertion seems to work.

then under Linux machines xpath stops working. Is there a workaround? I'm using soapUI 3.6.1.



[kk@centos ~]$ ./eviware/soapUI-3.6.1/bin/testrunner.sh ~/xxx_Admin-soapui-project.xml -Dsoapui.settings=/home/xxx/cobertura/soapui-settings.xml
================================
=
= SOAPUI_HOME = /home/xxx/eviware/soapUI-3.6.1
=
================================
soapUI 3.6.1 TestCase Runner
11:11:54,258 INFO [SoapUI] Adding [/home/xxx/eviware/soapUI-3.6.1/bin/ext/ojdbc14.jar] to extensions classpath
11:11:54,259 INFO [SoapUI] Adding [/home/xxx/eviware/soapUI-3.6.1/bin/ext/groovy-ldap.jar] to extensions classpath
11:11:54,259 INFO [DefaultSoapUICore] Creating new settings at [/home/xxx/soapui-settings.xml]
11:11:55,859 INFO [WsdlProject] Loaded project from [file:/home/xxx/xxx_Admin-soapui-project.xml]
11:11:57,397 INFO [log] server_url_apache:
11:11:57,398 INFO [SoapUITestCaseRunner] Running soapUI tests in project [Admin]
11:11:57,401 INFO [SoapUITestCaseRunner] Running Project [Admin], runType = SEQUENTIAL
11:11:57,428 INFO [SoapUITestCaseRunner] Running soapUI testcase [A00 - login ekraan on kƤttesaadav (OK)]
11:11:57,429 INFO [SoapUITestCaseRunner] running step [Request: open URL]
11:11:58,383 INFO [SoapUITestCaseRunner] Assertion [XPath Match - password input is found] has status UNKNOWN
11:11:58,383 INFO [SoapUITestCaseRunner] Assertion [XPath Match - username input is found] has status FAILED
11:11:58,383 ERROR [SoapUITestCaseRunner] ASSERTION FAILED -> XPathContains comparison failed, expecting [false], actual was [true]
11:11:58,383 INFO [SoapUITestCaseRunner] Assertion [Contains j_username] has status VALID
11:11:58,384 ERROR [SoapUITestCaseRunner] Request: open URL failed, exporting to [/home/xxx/Admin-A00__login_ekraan_on_kƤttesaadav_OK-Request_open_URL-0-FAILED.txt]
11:11:58,386 INFO [SoapUITestCaseRunner] Finished running soapUI testcase [A00 - login ekraan on kƤttesaadav (OK)], time taken: 65ms, status: FAILED
11:11:58,386 INFO [SoapUITestCaseRunner] Project [Admin] finished with status [FAILED] in 979ms
11:11:58,387 ERROR [SoapUITestCaseRunner] java.lang.Exception: XPath Match - username input is found in [Request: open URL] failed;
[XPathContains comparison failed, expecting [false], actual was [true]]
Status: FAILED
Time Taken: 65
Size: 2659
Timestamp: Fri Apr 22 11:11:57 EEST 2011
TestStep: Request: open URL

----------------- Messages ------------------------------
[XPath Match - username input is found] XPathContains comparison failed, expecting [false], actual was [true]

----------------- Properties ------------------------------
StatusCode: 200
Method: GET
HTTP Version: HTTP/1.1
Endpoint: http:///admin/login.do
URL: http:/admin/login.do

---------------- Request ---------------------------
Host: []
Accept-Encoding: [gzip,deflate]
User-Agent: [Jakarta Commons-HttpClient/3.1]

- missing request / garbage collected -

---------------- Response --------------------------
Content-Language: [et-EE]
Date: [Fri, 22 Apr 2011 08:11:57 GMT]
#status#: [HTTP/1.1 200 OK]
Content-Length: [2659]
Connection: [close]
Content-Type: [text/html;charset=UTF-8]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>KK Admin sisselogimise leht</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<link rel="shortcut icon" type="image/ico" href="/admin/gfx/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="/admin/gfx/_screen.css" media="screen,projection"/>
</head>
<body>
<!--INCOMING_IP=127.0.0.1
VERSION=1.4.3.17-->
<div id="login">
<div id="head">
<h1 id="logo"/>
</div>
<div id="content">
<div class="block">
<div class="form-title">
<h2 id="idcard">Sisene ID-kaardiga</h2>
</div>
<div class="inner">
<p class="form-indent">
<input type="button" value="Sisene" class="button" onclick="window.location='/admin/idsignon'; return false;"/>
</p>
</div>
</div>
<div class="block">
<div class="form-title">
<h2>Sisene kasutajanime ja salasƵnaga</h2>
</div>
<div class="inner">
<form method="post" action="j_spring_security_check">
<p class="form-row clear">
<label for="j_username">Kasutajanimi:</label>
<input type="text" id="j_username" name="j_username" class="text"/>
</p>
<p class="form-row clear">
<label for="j_password">SalasƵna:</label>
<input type="password" id="j_password" name="j_password" class="text"/>
</p>
<p class="form-indent">
<input type="submit" value="Sisene" class="button"/>
</p>
</form>
</div>
</div>
</div>
</div>
</body>
</html>

11:11:58,387 ERROR [SoapUI] An error occured [XPath Match - username input is found in [Request: open URL] failed;
[XPathContains comparison failed, expecting [false], actual was [true]]
Status: FAILED
Time Taken: 65
Size: 2659
Timestamp: Fri Apr 22 11:11:57 EEST 2011
TestStep: Request: open URL

----------------- Messages ------------------------------
[XPath Match - username input is found] XPathContains comparison failed, expecting [false], actual was [true]

----------------- Properties ------------------------------
StatusCode: 200
Method: GET
HTTP Version: HTTP/1.1
Endpoint: http:///admin/login.do
URL: http:/admin/login.do

---------------- Request ---------------------------
Host: []
Accept-Encoding: [gzip,deflate]
User-Agent: [Jakarta Commons-HttpClient/3.1]

- missing request / garbage collected -

---------------- Response --------------------------
Content-Language: [et-EE]
Date: [Fri, 22 Apr 2011 08:11:57 GMT]
#status#: [HTTP/1.1 200 OK]
Content-Length: [2659]
Connection: [close]
Content-Type: [text/html;charset=UTF-8]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>KK Admin sisselogimise leht</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<link rel="shortcut icon" type="image/ico" href="/admin/gfx/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="/admin/gfx/_screen.css" media="screen,projection"/>
</head>
<body>
<!--INCOMING_IP=127.0.0.1
VERSION=1.4.3.17-->
<div id="login">
<div id="head">
<h1 id="logo"/>
</div>
<div id="content">
<div class="block">
<div class="form-title">
<h2 id="idcard">Sisene ID-kaardiga</h2>
</div>
<div class="inner">
<p class="form-indent">
<input type="button" value="Sisene" class="button" onclick="window.location='/admin/idsignon'; return false;"/>
</p>
</div>
</div>
<div class="block">
<div class="form-title">
<h2>Sisene kasutajanime ja salasƵnaga</h2>
</div>
<div class="inner">
<form method="post" action="j_spring_security_check">
<p class="form-row clear">
<label for="j_username">Kasutajanimi:</label>
<input type="text" id="j_username" name="j_username" class="text"/>
</p>
<p class="form-row clear">
<label for="j_password">SalasƵna:</label>
<input type="password" id="j_password" name="j_password" class="text"/>
</p>
<p class="form-indent">
<input type="submit" value="Sisene" class="button"/>
</p>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
], see error log for details
java.lang.Exception: XPath Match - username input is found in [Request: open URL] failed;
[XPathContains comparison failed, expecting [false], actual was [true]]
Status: FAILED
Time Taken: 65
Size: 2659
Timestamp: Fri Apr 22 11:11:57 EEST 2011
TestStep: Request: open URL

----------------- Messages ------------------------------
[XPath Match - username input is found] XPathContains comparison failed, expecting [false], actual was [true]

----------------- Properties ------------------------------
StatusCode: 200
Method: GET
HTTP Version: HTTP/1.1
Endpoint: http:///admin/login.do
URL: http:/admin/login.do

---------------- Request ---------------------------
Host: []
Accept-Encoding: [gzip,deflate]
User-Agent: [Jakarta Commons-HttpClient/3.1]

- missing request / garbage collected -

---------------- Response --------------------------
Content-Language: [et-EE]
Date: [Fri, 22 Apr 2011 08:11:57 GMT]
#status#: [HTTP/1.1 200 OK]
Content-Length: [2659]
Connection: [close]
Content-Type: [text/html;charset=UTF-8]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>KK Admin sisselogimise leht</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<link rel="shortcut icon" type="image/ico" href="/admin/gfx/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="/admin/gfx/_screen.css" media="screen,projection"/>
</head>
<body>
<!--INCOMING_IP=127.0.0.1
VERSION=1.4.3.17-->
<div id="login">
<div id="head">
<h1 id="logo"/>
</div>
<div id="content">
<div class="block">
<div class="form-title">
<h2 id="idcard">Sisene ID-kaardiga</h2>
</div>
<div class="inner">
<p class="form-indent">
<input type="button" value="Sisene" class="button" onclick="window.location='/admin/idsignon'; return false;"/>
</p>
</div>
</div>
<div class="block">
<div class="form-title">
<h2>Sisene kasutajanime ja salasƵnaga</h2>
</div>
<div class="inner">
<form method="post" action="j_spring_security_check">
<p class="form-row clear">
<label for="j_username">Kasutajanimi:</label>
<input type="text" id="j_username" name="j_username" class="text"/>
</p>
<p class="form-row clear">
<label for="j_password">SalasƵna:</label>
<input type="password" id="j_password" name="j_password" class="text"/>
</p>
<p class="form-indent">
<input type="submit" value="Sisene" class="button"/>
</p>
</form>
</div>
</div>
</div>
</div>
</body>
</html>

at com.eviware.soapui.tools.SoapUITestCaseRunner.throwFailureException(SoapUITestCaseRunner.java:492)
at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:417)
at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:144)
at com.eviware.soapui.tools.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:82)
at com.eviware.soapui.tools.SoapUITestCaseRunner.main(SoapUITestCaseRunner.java:113)
[kk@centos ~]$

1 Reply

  • brigadir's avatar
    brigadir
    Occasional Contributor
    Alright, seems that Xpath does not seem to work under some linux distros when DOCTYPE element in HTML response is unclosed

    so
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    should be to get Xpath assertions working
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />


    it is strange that under Windows this does not seem to bother java xml parser