Skip to main content

Posts

Showing posts with the label regexp

Accurate Word Counter for non-Latin characters in Javascript regex

There is a problem that involves Javascript and regular expressions. The JS implementation of regexp does not support Unicode properly, for example /\b\S+\b/g regular expression will not count words with Unicode characters of many national alphabets and scripts, such as Cyrillic, Greek and Hindi. Unfortunately \S is restricted to Latin-only characters of English alphabet. To solve this problem we must explicitly include all Unicode characters. My solution is to use /([\u0080-\uFFFF\w]\u0027?)+/g regular expression instead. It covers the wide range of Unicode characters (from 0080 to FFFF) that includes all national alphabets + apostrophe symbol (0027). This regex has been tested with the following sample text and it counts all 55 words accurately, ignoring all special characters and punctuation, I used https://regexr.com to test it with this sample text that includes words from several alphabets.

JMeter handling dynamic ViewState parameter in Seam framework

Testing applications built with Seam Java framework is possible with JMeter like any other web applications, though there are some nuances to take into account. One of them is ViewState parameter. This parameter is dynamic and it means that we cannot just leave it hardcoded in our JMeter script because it will be broken the next time you try to execute it. Why this happens? Let's dig a little deeper. Black-box testing doesn't require us to know how Seam framework works, right? Okay, in this case we only need to know how it affects our tests. As testers we need to make sure that ViewState parameter in the POST request has the same value as returned by a previous GET request. For example you have two subsequent requests: GET http://x.x.x.x:8080/some_page.seam POST http://x.x.x.x:8080/some_page.seam The first request opens a page and the second one performs an action on the page (for instance - expands some tab, tree, etc). If you analyze the response data with a list