I'm having some problems getting the __VIEWSTATE and __EVENTVALIDATION parameters.
I'm using a post procesor Regular Expression Extractor and configuring them as follows:
Reference Name: aspViewstate
Regular Expression: name="__VIEWSTATE" id="__VIEWSTATE" value="(.+?)"
Template: $1$
Match No. (0 for Random): 1
Default value: ERROR_VIEWSTATE
Reference Name: aspEventValidation
Regular Expression: name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="(.+?)"
Template: $1$
Match No. (0 for Random): 1
Default value: ERROR_EventValidation
Then, Im replacing in the http request the values of each parameters for ${aspViewstate} and ${aspEventValidation} respectively.
I'm putting the Regular Expression Extractors below the GET request and before the POST request.
I'm including a Debug Sampler and Im getting the "error result":
aspEventValidation=ERROR_EventValidation
aspViewstate=ERROR_VIEWSTATE
Please can any one help me about what I'm missing....
UPDATE:
I'm getting the __VIEWSTATE using the CSS/JQuery Extractor like follow and is working:
CSS/JQuery Extractor Implementation:JSOUP
Reference Name: aspViewstate
CSS/JQuery Expression: input[id=__VIEWSTATE]
Attribute: value
Template: $1$
Match No. (0 for Random): 0
Default value: ERROR
but for the __EVENTVALIDATION is not working, and Im using the same sintax:
CSS/JQuery Extractor Implementation:JSOUP
Reference Name: aspEventValidation
CSS/JQuery Expression: input[id=__EVENTVALIDATION]
Attribute: value
Template: $1$
Match No. (0 for Random): 0
Default value: ERROR
I don't know what is failing...
About the VIEWSTATE Im getting already the value but the system is sending me the following error, is like is not sending the VIEWSTATE...
Error:
<code><pre>
[FormatException: The input is not a valid Base64 string that contains a character that is not Base 64, more than two filler characters or an invalid character among the padding characters . ]
System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength) +14115992
System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength) +162
System.Convert.FromBase64String(String s) +56
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +102
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +67
System.Web.UI.HiddenFieldPageStatePersister.Load() +200
[ViewStateException: View state invalid
Client IP:
Port:
Referer: http://Art/WebLogiPortal/wfmLoginD.aspx?ReturnUrl=%2fArt%2fWebLogiPortal%2fwfmDefault.aspx
Path: /Art/WebLogiPortal/wfmLoginD.aspx
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
ViewState: ${aspViewstate}]
[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +157
System.Web.UI.HiddenFieldPageStatePersister.Load() +12060517
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +12315765
System.Web.UI.Page.LoadAllState() +51
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +12308619
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +12308137
System.Web.UI.Page.ProcessRequest() +119
System.Web.UI.Page.ProcessRequest(HttpContext context) +99
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
</pre></code>
I added a Debug Post procesor and I realized that the sent value to the server was litterally the characters of the variable (i.e ${viewstate}) and not the value, not even the default value (error).
What can possibly be happening ?
Here is the Response date of the Debug Post procesor:
HTTPSampler.response_timeout=
HTTPSampler.use_keepalive=true
HTTPsampler.Arguments=wucLoginPortal_ScriptManager1_HiddenField=&__EVENTTARGET=&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=${aspViewstate}&__VIEWSTATEGENERATOR=${viewstateGenerator}&__EVENTVALIDATION=${aspEventValidation}&wucLoginPortal$__LBLHDN__=&wucLoginPortal$txtLoginAD=user1&wucLoginPortal$txtPasswordAD=user1&wucLoginPortal$txtDominioAD=art.com&wucLoginPortal$btnAceptarAD=Aceptar
TestElement.enabled=true
TestElement.gui_class=org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui
TestElement.name=4 /Art/WebLogiPortal/wfmLoginD.aspx?ReturnUrl=%2fArt%2fWebLogiPortal%2fwfmDefault.aspx
TestElement.test_class=org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy
TestPlan.comments=Detected the start of a redirect chain
I wouldn't recommend using Regular Expression Extractor to fetching viewstate and eventvalidation values as in case of changing attributes location, or being on multiple lines or having an extra space may cause your regex to fail.
JMeter provides 2 test elements designed to extract values from HTML pages, they are:
XPath Extractor
CSS/JQuery Extractor
Example XPath locator will look like:
//input[#id='__VIEWSTATE']/#value
Example CSS selector will be
input[id=__VIEWSTATE]
specify value in "Attribute" input
See ASP.NET Login Testing with JMeter guide for more details and recommendations.
Related
I have a method in our software that pulls the text from a PDF, from a scan or text generated.
I usually try the GetTextFromPage() method first. If it doesn't return text, then I move onto OCR'ing the page.
I have a particular 6 page PDF with the first three pages being a scanned document, and the last two being a form.
On this PDF I'm getting an error that I can't figure out how to resolve.
'StandardEncoding' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
at System.Globalization.EncodingTable.internalGetCodePageFromName(String name)
at System.Globalization.EncodingTable.GetCodePageFromName(String name)
at iText.IO.Util.IanaEncodings.GetEncodingEncoding(String name)
at iText.IO.Util.EncodingUtil.ConvertToBytes(Char[] chars, String encoding)
at iText.IO.Font.PdfEncodings.ConvertToBytes(String text, String encoding)
at iText.IO.Font.FontEncoding.FillNamedEncoding()
at iText.IO.Font.FontEncoding.CreateFontEncoding(String baseEncoding)
at iText.Kernel.Font.PdfType1Font..ctor(PdfDictionary fontDictionary)
at iText.Kernel.Font.PdfFontFactory.CreateFont(PdfDictionary fontDictionary)
at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.GetFont(PdfDictionary fontDict)
at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.SetTextFontOperator.Invoke(PdfCanvasProcessor processor, PdfLiteral operator, IList`1 operands)
at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.InvokeOperator(PdfLiteral operator, IList`1 operands)
at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.ProcessContent(Byte[] contentBytes, PdfResources resources)
at iText.Kernel.Pdf.Canvas.Parser.PdfTextExtractor.GetTextFromPage(PdfPage page, ITextExtractionStrategy strategy, IDictionary`2 additionalContentOperators)
at iText.Kernel.Pdf.Canvas.Parser.PdfTextExtractor.GetTextFromPage(PdfPage page)
at EFR.OCR.OCR.ExtractTextFromPDF(FileInfo fileInfo, Int32 StartingPage, Int32 NumberOfPages) in P:\Cloud\Dropbox\EF Recovery\OCRTest\EFR.OCR\OCR.vb:line 113
I've processed many PDFs through my code, some text, some scans, some mixed together. Some had forms... This is the first time that I've had this error.
Here's a snippet of my code...
Using reader As New iText.Kernel.Pdf.PdfReader(fileInfo.FullName)
reader.SetUnethicalReading(True)
Using sourceDoc As New iText.Kernel.Pdf.PdfDocument(reader)
If NumberOfPages = 0 Then NumberOfPages = sourceDoc.GetNumberOfPages
For i As Integer = StartingPage To StartingPage + NumberOfPages - 1
Dim pageText As String = ""
Try
pageText = iText.Kernel.Pdf.Canvas.Parser.PdfTextExtractor.GetTextFromPage(sourceDoc.GetPage(i))
Catch ex As Exception
OCRLog.Log($"Error attempting to extract text from page {i}. {ex.ToString}")
End Try
If pageText = "" Then
'extract this page
Dim results As OCRResults = ExtractTextFromPDFImagePage(fileInfo.FullName, i)
pageText = results.Text
pageItems.Add(New OCRResults.PagesClass(results.Accuracy, True, pageText))
Else
pageItems.Add(New OCRResults.PagesClass(100, False, pageText))
End If
stringBuilder.Append(pageText)
Next
Return New OCRResults(stringBuilder.ToString, pageItems)
End Using
End Using
Any ideas?
There is an error in the PDF, just as indicated by the error text "'StandardEncoding' is not a supported encoding name.".
The fonts on the page you shared use the name StandardEncoding in their Encoding entries. This is not a valid name here. According to the specification ISO 32000-1 the only valid values here are MacRomanEncoding, MacExpertEncoding, and WinAnsiEncoding, see Table 111 – Entries in a Type 1 font dictionary – and Table 114 – Entries in an encoding dictionary.
Adobe Preflight also complains about these names when checking for syntax errors:
An unexpected value is associated with the key
Key: BaseEncoding
Value: /StandardEncoding
Type: CosName
Formal Representation: Encoding
Cos ID: 38
Traversal Path: ->Pages->Kids->[0]->Resources->Font->WARSP->Encoding
An unexpected value is associated with the key
Key: Encoding
Value: /StandardEncoding
Type: CosName
Formal Representation: Font.FontType1
Cos ID: 27
Traversal Path: ->Pages->Kids->[0]->Resources->Font->Arial,Bold
An unexpected value is associated with the key
Key: BaseEncoding
Value: /StandardEncoding
Type: CosName
Formal Representation: Encoding
Cos ID: 22
Traversal Path: ->Pages->Kids->[0]->Resources->Font->Arial->Encoding
An unexpected value is associated with the key
Key: BaseEncoding
Value: /StandardEncoding
Type: CosName
Formal Representation: Encoding
Cos ID: 19
Traversal Path: ->Pages->Kids->[0]->Resources->Font->ARROW->Encoding
(Excerpt from a preflight report for your shared PDF)
In spite of StandardEncoding not being a valid name here, the PDF specification knows a "Standard Encoding", see Annex D of ISO 32000-1. Most likely your document attempts to refer to that encoding at the locations outlined above.
If you need to extract text from the document in question, therefore, you may want to follow the recommendation of the error message:
For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
The Encoding class here is the one in System.Text.
To extract the text from your PDF, therefore, it should suffice to implement an EncodingProvider that for the name StandardEncoding provides an Encoding instance according to the information from the STD column of the table in Annex D.2 – Latin Character Set and Encodings – of ISO 32000-1.
I am trying to POST HTTP request and request is not going thru. what am I doing wrong or missing?
I think it does not like this part
colonoscopy.jpg/1-1?
Server name: ${hostName}
Path: ${virtualDirectory}/data/media/${location}/colonoscopy.jpg/1-1?&prodName=${prodName}&otherParams=&sid=${authToken}
HTTP Header Manager
Content-Type application/x-www-form-urlencoded
Getting
Thread Name: Thread Group 1-1
Sample Start: 2019-02-01 15:39:06 PST
Load time: 0
Connect Time: 0
Latency: 0
Size in bytes: 1681
Sent bytes:0
Headers size in bytes: 0
Body size in bytes: 1681
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: Non HTTP response code: java.net.URISyntaxException
Response message: Non HTTP response message: Illegal character in path at index 53: http://10.188.169.185/api/v2/data/media/dc2e83cfe2054
Server:%20Microsoft-IIS/10.0
Set-Cookie:%20ASP.NET_SessionId=5cwq0inclxwvmd0qlnd01yo3;%20path=/;%20HttpOnly
X-AspNet-Version:%204.0.30319
X-Powered-By:%20ASP.NET
Access-Control-Allow-Origin:%20*
Access-Control-Allow-Headers:%20Content-Type,Authorization
Access-Control-Expose-Headers:%20Content-Location,%20Location
Access-Control-Allow-Methods:%20GET,%20POST,%20OPTIONS,%20DELETE
Date:%20Fri,%2001%20Feb%202019%2023:39:05%20GMT
Content-Length:%200
colonoscopy.jpg/1-1?&prodName=test&otherParams=&sid=ca1bc7a576a44d9b8270b7cac2dddab8
HTTPSampleResult fields:
ContentType:
DataEncoding: null
Inspect your URL along with the query string using View Results Tree listener, the error can have only one reason: you're sending a character which requires URL encoding as it is.
The reasons are in:
One of your variables (${location}, ${prodName} or ${authToken}) has the character which requires the URL encoding. If this is the case - you will need to wrap it into __urlencode() function
One of your Variables (${location}, ${prodName} or ${authToken}) is not getting resolved into the value and curly braces characters ({ and }) are not allowed in the URL string without encoding. Use Debug Sampler to make sure that :
all the variables have their values
all the characters which require the encoding are encoded using the __urlencode() function
I would like to capture response Header value for "Authorization:".
Response headers:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json
Server: Microsoft-IIS/8.5
Authorization: Bearer MMSArOve7c9NffH4oTqBMW1SiWLUbQi2nm0ryR-
Wi5d_plLkk7xzTVo8b5_s1sg-Rut6vdDoTvlRju-
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 14 May 2018 03:50:47 GMT
Content-Length: 484
and I did this.
but the result is
JMeterVariables:
JMeterThread.last_sample_ok=true
JMeterThread.pack=org.apache.jmeter.threads.SamplePackage#33a6821
START.HMS=113828
START.MS=1526254708675
START.YMD=20180514
TESTSTART.MS=1526269844536
Token=test
__jm__Thread Group__idx=0
__jmeter.USER_TOKEN__=Thread Group 1-1
what I did wrong, please help Thank you!
You can use the following regex to extract Authorization
Bearer (((.*)\n)+)X-Asp
And Use Match No 1
For More information you may link to the following
JMeter Regular Expressions
Extracting variables
Don't use ^ which is Start of String Anchor
Applying ^a to abc matches a. ^b does not match abc at all, because the b cannot be matched right after the start of the string, matched by ^
So use the regular expression without it:
Bearer(.*)
You need to remove ^ character from your regular expression
More information:
Regular Expressions
Perl 5 Regex Cheat sheet
Using RegEx (Regular Expression Extractor) with JMeter
How to use regular expression extractor to extract Etag from http-header response?
I've the following output from my get and I want to extract Etag and use it in my next case where i've to pass it in my http-header to do If-None-Match. I've tried the following: \Etag:\s? and have chosen "Headers" in "Response Field to Check". But I don't see this value being sent to my header.
Thread Name: Fetch_Links 1-1
Sample Start: 2012-05-24 10:15:10 PDT
Load time: 135
Latency: 131
Size in bytes: 4950
Headers size in bytes: 641
Body size in bytes: 4309
Sample Count: 1
Error Count: 0
Response code: 200
Response message: OK
I'm using 2.6 version of jmeter. Thank you in advance.
I'm able to extract the ETag in JMeter (Regular Expression Extractor - Headers) with the following parameters:
Regular Expression: ETag: "(.*?)"
Template: $1$
Then add a HTTP Header Manager to pass the value of the Etag with 'If-None-Match'.
I'm running into a problem with an optional regex clause (\.ashx)? in an ASP.NET MVC route
routes.IgnoreRoute("resizer\\.debug(\\.ashx)?");
routes.IgnoreRoute("[^?]+\\.(psd|bmp|gif|exif|png|tif|tiff|tff|jpg|jpeg|jpe|jif|jfif|jfi)(\\.ashx)?");
I get the error
The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character.
Parameter name: routeUrl
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character.
Parameter name: routeUrl
[ArgumentException: The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character.
Parameter name: routeUrl]
System.Web.Routing.RouteParser.Parse(String routeUrl) +21953
System.Web.Routing.Route.set_Url(String value) +12
System.Web.Routing.Route..ctor(String url, IRouteHandler routeHandler) +9
System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url, Object constraints) +106
System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url) +6
MvcApplication2.MvcApplication.RegisterRoutes(RouteCollection routes) in C:\Users\Administrator\Documents\resizer\Tests\Hidden\MvcApplication2\Global.asax.cs:15
MvcApplication2.MvcApplication.Application_Start() in C:\Users\Administrator\Documents\resizer\Tests\Hidden\MvcApplication2\Global.asax.cs:29
How do you do optional regex groups in MVC routes?
You could try:
http://www.iridescence.no/post/Defining-Routes-using-Regular-Expressions-in-ASPNET-MVC.aspx