How to detect colorisation on a text box with Squish and Robot framework? - robotframework

I have a desktop application that has a form that people fill out in text boxes. If an invalid value is entered, then the box turns pink with a red border. I am using Robot framework with Squish to try and identify this error when it occurs on a certain textbox. What is the best way to do this?

Typically in QT, when actions happen they are firing signals and a slot in certain component. I'd assume that the state of the component is handled with something that triggers a signal that and the textbox receives it.
You could try to monitor what gets triggered when invalid input is given and use that in your asserts..
Another way, you might be able to read the property of your text input widget and see what changes when invalid input is given ..

Getting the internal state that results in alteration of the rendering may not be straightforward, but at least depends on which GUI technology is in use. (You have not told us yet, I think.)
A simpler approach is to use a screenshot verification point (SVP) for just that control. In that SVP, you can use a positive mask to mark a specific area that is least likely to be affected by the contents of the control (to make the SVP as robust as possible).
A similar approach is to use (verifying the actual pixel colors used for rendering on the screen) object.grabScreenshot() and use the API of the returned Image Object to query the color of an individual pixel via Image.getPixelRGB(x, y) and Image.getPixelRGBA(x, y).

Related

Qt style sheets are not applied immediately

I have a console window in my Qt application whose output window is a specialised QTextEdit, outputting messages that are processed after a command is parsed from a QLineEdit and subsequently executed by the main program. The window can output normal messages, warnings and, if desired, text in a number of 6 different custom colours. All 8 different types of text have their colour defined by 8 different QProperties of type QColor; these are set, along with the rest of the output window's styling, through the use of a QSS file applied to the QApplication when it loads. To write text in a certain colour, setTextColor is called on the QTextEdit just before inserting the text. (As an aside, moveCursor when called on the QTextEdit appears to reset the colour of the text to be inserted to the default colour regardless of what it was set to before, but I've made sure to set the desired text colour immediately after calling moveCursor and before calling insertPlainText.)
The problem I am having is that it appears (as far as I can see) that the styling applied through qApp->setStyleSheet is not actually applied until the message queue is processed. When the program starts it applies the style sheet and shortly afterwards a hard-coded test message is sent to the console window showing the date and time of the last compile. This message ends up being printed in the original QTextEdit colour (black), which is invisible after the black background colour in the style sheet is applied. The problem is not as simple as setting the standard text colour of the console window when the style is applied, as any number of messages could potentially be sent to the console window before the styling takes effect, resulting in any number of differently coloured messages.
I am trying to think of the best way to remedy this problem. The best way I can think of at the moment is a tagging method where messages would be enclosed in semantic tags (eg. all warning messages would be enclosed in HTML-like tags to specify that they are warnings), and when a console window's styling is applied each message would be re-coloured according to the new styling. This would obviously require hooking into some "OnStyleApplied" event for the QTextEdit. Would this be possible, or is there a better method to resolve this?
If it is really applying the qstylesheet changes in the message queue, tell the message queue to get processed before your next call.
http://qt-project.org/doc/qt-5.0/qtcore/qcoreapplication.html#processEvents
You can even specify which class of events that should be processed.
The other way that should work, is you can specifically tell the widget to apply its style changes when you want it to.
I put together an in-depth look at some advanced stuff with qstylesheets the other day:
QList: Out of memory
Note the use of polish and unpolish in the link above.
But besides all of the direct answers, you may want to look into using the classes that are made for rich text editing:
http://qt-project.org/doc/qt-5.0/qtgui/richtext.html
The structure is well thought out and you can do a lot with them. There is a learning curve to figuring them out, but it works well.
This is kind of related to what you are talking about...
Also here is a neat tool that Qt has:
http://qt-project.org/doc/qt-5.0/qtcore/qtglobal.html#qInstallMessageHandler
When you combine that with <some text editor/viewer class qt has>.append();, then when you want to add text, you can just use the qDebug() << call, and you get all the niceties of inserted spaces, newlines, and auto rendering of many Qt Classes debug string representations.
Hope that helps.

flex chat/telnet application send/receive same window in TextArea

Just wanting to know if anybody has seen an example of a telnet/chat or other console like FLEX application where you can use the same TextArea as input/ouput area.
I've been trying to modify the app at:
http://livedocs.adobe.com/flex/3/html/17_Networking_and_communications_8.html
but so far, computer says no.
All the implementations I've seen use a combination of TextInput and TextArea.
The challenge is that we'll be using this app to telnet into some old routers and we'll need to do a fair amount of copy/pasting. Based on what I've seen, it seems that I would need to point the mouse into the TextInput in order to be able to right click and paste, which is not very sleak.....
Your thoughts,
Fran
edit Just realized that I had trimmed out what was directly pertaining to the question: I was unable to find anything that used the TextArea for input and output; see the below suggestions if custom-component suggestions are ok.
The TextArea component only fires a change event whenever a user adds input. Whenever you set the text field programmatically, a change event does not fire--you could maybe use that as a way to know what is user input and console "responses" by looking for carriage-returns (\r).
I'm unsure if you have a requirement to maintain the user's input at the bottom-most line (like a console), even after the console responds with something like auto-complete. If that's the case, then something a bit more complex would have to come into play (such as remembering where the user's input started/ended) or the requirement of a single-component console needs to be reconsidered--sleek is nice, but not always necessary.

Can I suspend drawing to perform multiple successive updates in Flex?

I've written a simple calendar control to allow for selecting single days, weeks, months and so on. The simplicity comes from the fact that I don't really do any drawing myself, opting instead to create a bunch of boxes and labels to act as date cells for the calendar.
When a date or a date range is selected, I need to highlight that range. It's easily done by iterating through the cells and switching their style. [edit:] However, this seems to cause a delay during which the cells are first drawn as if the style name was blank, and then re-drawn with the correct style, despite the fact that I never explicitly set the style to null -- I alternate between "CalendarCell" and "CalendarCellSelected".
If this were Windows Forms, I'd call SuspendLayout on the parent container to make sure the controls are repainted only after I've finished the updates. What I'm looking to know is whether or not a similar solution exists for Flex. I'd like to avoid drawing the entire calendar "manually", so to speak, if that's at all possible.
edit: changed the problem description to more accurately reflect what I'm seeing.
Are you using callLater() at all?
If you use callLater() it may impove your visuals as it batches up changes until it needs to draw a frame or you force a frame draw with validateNow() or similar. It might be enough in your case.
Is your calendar control a UIComponent? Is it using the standard invalidation methods like commitProperties(), updateDisplayList(), etc?
What you might want to do is keep a private array of the cells that will have their styles changed, but then do the actual style switching in your commitProperties() override. I'm just not sure if setStyle() fires an validateNow() because the flickering is a bit surprising.
This may not be exactly what you're looking for, but David Coletta at Adobe has posted a video explaining an EventCoalescer that they use in Buzzword for deferring events that update specific areas of the app UI until the user has stopped moving the insertion point in the text, for example.
This blog post by Hans Van de Velde also has a similar solution, and actual code for it as well.

How can I disable an individual item in a combo box in Flex so that it is not clickable?

I want to create a combobox in flex which will take three values, Available, Unavailable, and Busy. The constraint is, I should not allow user to go directly from Unavailable to Busy. So when a User is selected Unavailable, I should keep the Busy item disabled (unselectable), but a user will be able to go directly from Available to Busy. I chouldn't find a straight forward way to disable an item in combobox in Flex. How can I do that?
Have you considered using radio buttons rather than a combo box? It's clear how to do this for radio buttons, for one thing. Also, it can often be friendlier to present the available options without requiring a click to reveal them. (Especially if, as in this case, you are adding the possibility that an option is "available, but not possible for you right now for some reason not shown in this combo-box item").
If you really want a combo-box, you can use the click event to display it in a non-standard fashion by probably changing its style; and then, if clicked anyway, Then, in the selected event, reject the choice (hopefully with an indication of why),
Or, if you want to simply remove it from the list, you can have the click listener event repopulate the source list each time, based on conditions. But that might be confusing to the user, too.
You can also have a look at
www.stoimen.com/blog/2009/03/05/flex-3-combobox-disabled-options/
which references
wmcai.blog.163.com/blog/static/4802420088945053961/
(note for NoScript users you must have 163.com and 126.com at least temporarily allowed to be
able to properly see this page)
it works very well even though I added the code for being able to properly handle keyboard
events in the dropdown list
Full self working example available at
http://olivierbourdon.homedns.org/OpenSource/combos.zip
Thanks again for the good work

Mercury Quick Test Pro - Testing with a custom grid

We are trying to create some tests that reference an vendors custom grid. Unfortunatly QTP only recognises it as a WinObject which is quite useless. We need to be able to navigate the grid and change cell values, double click on a cell(without using X,Y co-ordinates) etc.
Ideally we want to get QTP to understand that this object is a grid and treat it as one.
Any help would be greatly appreciated.
Thanks
Jon
What vendor?
I have a few suggestions:
Use key strokes to navigate the grid, rather than mouse clicks. Ctrl-Home to set focus to the top-left cell, then use up, down, left, right to move around. Use Enter keystroke to simulate double clicking. Often you can use Ctrl-A, Ctrl-C to copy the contents of the grid to the system clipboard, and use the clipboard API to retrieve the data.
You may be able to programmatically get/set the grid properties using the .Object property. .Object provides access to the underlying native properties and methods of the object, as opposed to the QTP methods and properties. You could do something like the following pseudo-code to set focus to a cell and change the value. Your code would differ depending on the vendor implementation. Consult the vendor's documentation to find out what methods and properties you would be able to use.
WinObject("mygrid").Object.CurRow = 1
WinObject("mygrid").Object.CurCol = 1
WinObject("mygrid").Object.Value = "my new value"
If the grid in question happens to be a Stingray Objective Grid, QTP has plugins specifically for that.
Same thing for Infragistics. They have a plug-in for QTP for the UltraWinGrid etc.
http://www.infragistics.com/dotnet/testadvantage.aspx#Overview
It is resonable to send the request to Support Center. If they will get a big number of requests - they will add support for your grid-vendor.
May be you forgot to load (install) AddIn for your grid-vendor.

Resources