Added PassIfNotFound to XPathExtractionRule
Showing
1 changed file
with
9 additions
and
6 deletions
... | @@ -52,6 +52,11 @@ namespace WebTest.WebService.Plugin.Runtime | ... | @@ -52,6 +52,11 @@ namespace WebTest.WebService.Plugin.Runtime |
52 | set { randomMatch = value; } | 52 | set { randomMatch = value; } |
53 | } | 53 | } |
54 | 54 | ||
55 | [DisplayName("Pass if not found")] | ||
56 | [Description("If set to true, this rule will pass the request even if no match is found.")] | ||
57 | [DefaultValue(false)] | ||
58 | public bool passIfNotFound { get; set; } | ||
59 | |||
55 | /// <summary> | 60 | /// <summary> |
56 | /// The Extract method. The parameter e contains the Web test context. | 61 | /// The Extract method. The parameter e contains the Web test context. |
57 | /// </summary> | 62 | /// </summary> |
... | @@ -62,11 +67,7 @@ namespace WebTest.WebService.Plugin.Runtime | ... | @@ -62,11 +67,7 @@ namespace WebTest.WebService.Plugin.Runtime |
62 | try | 67 | try |
63 | { | 68 | { |
64 | ContentHandler contentHandler = ContentHandlerFactory.GetHandler(e.Response.ContentType); | 69 | ContentHandler contentHandler = ContentHandlerFactory.GetHandler(e.Response.ContentType); |
65 | if (contentHandler == null) | 70 | if (contentHandler != null) { |
66 | { | ||
67 | return; | ||
68 | } | ||
69 | |||
70 | if (contentHandler.IsBinary) | 71 | if (contentHandler.IsBinary) |
71 | { | 72 | { |
72 | contentHandler.MessageBytes = e.Response.BodyBytes; | 73 | contentHandler.MessageBytes = e.Response.BodyBytes; |
... | @@ -114,12 +115,14 @@ namespace WebTest.WebService.Plugin.Runtime | ... | @@ -114,12 +115,14 @@ namespace WebTest.WebService.Plugin.Runtime |
114 | return; | 115 | return; |
115 | } | 116 | } |
116 | } | 117 | } |
118 | } | ||
117 | catch (Exception ex) | 119 | catch (Exception ex) |
118 | { | 120 | { |
119 | e.Message = ex.Message; | 121 | e.Message = ex.Message; |
120 | } | 122 | } |
121 | 123 | ||
122 | e.Success = false; | 124 | e.Success = passIfNotFound; |
125 | e.Message += " (XPath not found)"; | ||
123 | return; | 126 | return; |
124 | } | 127 | } |
125 | } | 128 | } | ... | ... |
-
Please register or sign in to post a comment