This is a migrated thread and some comments may be shown as answers.

reg-ex verification doesn't work correctly (inside an if-else condition))

6 Answers 129 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniele Bruno
Top achievements
Rank 1
Daniele Bruno asked on 26 Jan 2016, 10:36 AM

hello again,

today I have to test if a textarea of an application has been populated with information and, if so, give some feedback to the tester.

the point is:

I need to build a verification which checks if the value of a textarea is still the empty string ("") or if it has been written upon.

I tried many ways looking in the documentation, in examples and so on, and I have come up trying to use a simple regular expression to do this check. I've built an if-else condition which bears a verification that works somewhat like this (see screenshot):

"if this element's text-attribute's value is != ".+" (which should mean "one or more any character" in regex), prompt a windows that says so, if not, prompt another window that says the opposite"

if I run this test on two elements, one with the desired textarea full of text and the other empty, in both cases my verification seems to give positive feedback.

I am missing something, or maybe the regex is not validated.

coul you give me a hand on this?

thanks in advance to anyone who could teach me how this works.

6 Answers, 1 is accepted

Sort by
0
Daniele Bruno
Top achievements
Rank 1
answered on 26 Jan 2016, 11:16 AM

actually, the screen is wrong:

I was trying the regex ".+" solution, but also the exact: "" one, so that was a mistake.

the things I've tried are in the following image

0
Ivaylo
Telerik team
answered on 29 Jan 2016, 07:26 AM
Hello Daniele,

I guess what you are trying to complete is only possible using a coded solution. However without an access to the actual section of the application we cannot assist you further.

Do you think you can provide us with access so we can give it a try?

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Daniele Bruno
Top achievements
Rank 1
answered on 05 Feb 2016, 07:57 AM

hello there,

I wish I could, but since we are currently testing a product in development I am not allowed to show the application or grant external access to our test machines.

but maybe I could provide you with sufficient infos about the DOM structure around that element to give you the right insight to help me out, I'll try and give you the details as soon as I can.

fro now, thank you very miuch

0
Ivaylo
Telerik team
answered on 09 Feb 2016, 12:34 PM
Hi,

You are most welcome.

Whenever you provide sufficient details we can continue working on this case. I am leaving this case in stand by awaiting your reply.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Daniele Bruno
Top achievements
Rank 1
answered on 15 Feb 2016, 09:05 AM

hello again Ivalyo,

so let me try to explain my situation better with some more information.

I am building a test case that needs in a certain step to check if a form has text in it or not.

In the web application I am testing there's a process that scans an image for text (an optical character recognition process); if this process finds characters, it writes them in the form in question, if it doesn't, it stays empty.

this form is accessed by the user displaying infos on a given document and it is a simple textarea tag, I am attaching a screenshot in which it shows a document which has a form WITH text (not empty).

the problem is that inside the tag itself in the code of the page there is NO TEXT, the page code (got locating in the DOM the given element of the page) is the one that follows:

<div class="popupBox">
  <div class="popupVoci" style="">Testo OCR:</div>
  <div>
    <textarea rows="12" name="" id="infoFileElementTextarea_ocr_text" class="infoFileElementTextarea" readonly="true" value="" style="height:auto;">
    </textarea>
  </div>
</div>

as you can see from this pasted HTML and from the screenshot the tag which I am trying to check is th one called "infoFileElementTextarea_ocr_text"

up until now, every verification I tried inside Test Studio went wrong, indifferently from the logic implemented, I could never actively verify if the element has text in it or not, since this tag stays empty in any given case.

I hope i shed some light on this matter

until next time

0
Ivaylo
Telerik team
answered on 17 Feb 2016, 11:41 AM
Hello Daniele,

Thank you for providing additional information and the code snippet. I can see that the value is empty. Is that from your browser or this is pulled out from Test Studio's DOM tree?

Please note that if this is a result from the browser the behavior you are experiencing is quite expected.

Looking forward to hearing from you. 

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Daniele Bruno
Top achievements
Rank 1
Answers by
Daniele Bruno
Top achievements
Rank 1
Ivaylo
Telerik team
Share this question
or