Text validation for Windows applications - automated-tests

I'm writing automation tests for a windows application using Sikuli/Robotframework, I want to be able to validate text that I see on the application but the values change so would be using a variable created at the start of each test run, is there anyway to validate that the text value is present in the application using Sikuli if not where should I look for validation?

I just had a look at SikuliLibrary
There is a Keyword called "Get Text" where it returns the text when an image file is passed. You can then store it in a variable and then make use of String comparison operation.
Get text - from library
Two ways in which you can retrieve text.
If image is not given, keyword will get text from whole Screen
If image is given, keyword will get text from matched region Call keyword setOcrTextRead to set OcrTextRead as true, before using text recognition keywords.
Examples:
Set Ocr Text Read true
Get Text
Get Text test.png
String comparison operation
Should be equal as strings ${only value} ${sele}

Related

How do I get hidden text from text field by robotframework

I used this statement but got error
${searchbox_title} Get Text //form[#role='search']//input[#aria-label='ค้นหาใน เสื้อผ้าแฟชั่นผู้ชาย']
Error msg
Element with locator '//form[#role='search']//input[#aria-label='ค้นหาใน เสื้อผ้าแฟชั่นผู้ชาย']' not found.
You seem to be trying to get the value from a dynamic element. The input field has that content after being written by the user or robot. Why not trying a different locator, for example:
//form[#role='search']/input[#class='shopee-searchbar-input___input']

Trying to search through text on a website in PlayWright API

The text I'm searching for is all contained within a CSS class called "content-center", and within that is a series of CSS classes all with the same name that old similar, but different information. It seems to only be returning [<JSHandle preview=JSHandle#node>] rather than returning the text itself as if saying "yes, this text is on the page X times".
page.wait_for_selector('.content-center')
print(page.query_selector_all(".content-center:has-text('Bob Johnson')"))
page.query_selector_all returns the ElementHandle[] values of the elements which got found. Over these you can loop and call the text_content() method to get the text out of that specific element.
Also in most cases, its enough to use the text-selectors to verify something is on the page or an element has text, see here for reference.

Visual FoxPro 9.0 report show unicode

I am using Visual Foxpro 9, I want to print Unicode chars in report (frx).
There are some ways to extend report listener to show unicode. I need the code to extend/show reportListner to show unicode.
I've never had to work with Unicode within VFP either, or spent any time working with Reports, but the Help for the Render method of the ReportListener does mention Unicode:
cContentsToBeRendered
Indicates the text to be rendered for Expression (Field) and Label layout elements.
For Picture layout elements sourced from a file, cContentsToBeRendered contains the filename.
When specifying a filename for an image, ReportListener provides cContentsToBeRendered
as a DBCS string, which is the standard format for strings in Visual FoxPro.
However, when indicating text to be rendered, ReportListener provides
cContentsToBeRendered as a Unicode string, appropriately translated to the correct
locale using any regional script information associated with this layout control in
its report definition file (frx) record.
If your derived class sends the text value through some additional processing, such as
storage in a table, you can use the STRCONV() function, and its optional regional
script parameter, to convert the string to DBCS first. For more information, see
STRCONV( ) Function.
Although I could be incorrect, but I believe VFP does NOT support UniCode and only works with the base ASCII character set. But then again, I've never needed to use Unicode either and have used FoxPro since the beginning of its lifetime.
I would imagine Rick Strahl's article Using Unicode in Visual FoxPro
Web and Desktop Applications would be fairly definitive on the topic.

Print plain text to printer (paper)

I have a QPlainTextEdit widget that holds text that the user entered. The text might contain \n characters or it may all be on one very long line. My objective is to print this text on a printer (on paper) with word wrapping. The functions QPlainTextEdit::print() and QTextDocument::print() are not suitable to me because they both print the page number at the bottom of the page, which I don't want, and second, I can't seem to be able to control which pages to print (for example if the user only wants to print page #2 out of 5 pages) - the entire document is always printed.
Basically I am using a QPainter object to paint the text on the printer. The main difficulty I am facing is determining when to call QPrinter::newPage() function. How do you determine how much text will fit on a page? If the text is on one long line and the line is being word wrapped, how do you know when the first page is full and when to start a second page? I use the following code to draw:
painter.drawText(printer->pageRect(), Qt::TextWordWrap, ui->plainTextEdit->toPlainText());
painter is of type QPainter; printer is of type QPrinter; plainTextEdit is of type QPlainTextEdit.
To get the vertical size of your text, call painter.boundingRect( painter.window(), myText ).height();. When that exceeds painter.window.height(), it's time to call newPage().
Now it's just a matter of building up your text word-by-word until the boundingRect height exceeds the page height. I'd suggest keeping a "safe" QString that you know will fit on a page and an "unsafe" QString that you just added the new word to. If the new word didn't exceed the height, then assign the safe string to the unsafe one. (Qt has some optimizations like shared copying to keep this from being too compute intensive).
To deal with individual words in a QString, you'll want to play with indexOf() or split() using their QRegExp variants so you can search for whitespace like spaces, tabs, newlines.
You'll have to account for a single "word" that itself won't fit on a page, and split it up mid-word. There may be other devils in the details but hopefully that gets you a good start.

How to place a carriage return in the text for an ENTITY?

In my dtd file for my localization strings for the xul of my addon, I have a very long string in which I need a carriage return.
<!ENTITY myentity.label "THIS IS A TEST OF THE EMERGENCY BROADCAST SYSTEM. **break** REPEAT: THIS IS ONLY A TEST.">
What can I put in please of break in my example?
My dtd file is encoded as UTF-8 without BOM.
I've tried (in place of the break):
\u000D
\u000D\u000A
%0D%0A
And I've tried adding a literal carriage return, too.
<!ENTITY myentity.label "THIS IS A TEST OF THE EMERGENCY BROADCAST SYSTEM.
REPEAT: THIS IS ONLY A TEST.">
but when the string shows in the dialogue window in Firefox, it still shows as one long line with no breaks - which means the text runs off the edge of the dialogue box.
It seems like I should use the unicode code for the character, but when I add that, it just prints literally.
You cannot put a carriage return in an entity directly.
If the entity is the text content of a <description>, you can add xmlns:html="http://www.w3.org/1999/xhtml to your window or overlay definition and then use <html:br/> in your entity.
The preferred way to do what you are trying to do is to set a max width on the XUL description entry via CSS and allow it to wrap. For this to work, the text must be a child of the description (not the value attribute).
See:
https://developer.mozilla.org/en-US/docs/XUL/description

Resources