indexing not reliable on WindowCollection - ruby

I have upgraded to recent WATIR(7.0.0.beta5) and when I am executing the following line
#browser.windows.last.use
I am getting this error
"indexing not reliable on WindowCollection"
This was working fine in my previous WATIR version(6.19.1). What is the issue?
Another question is, It looks like there are plenty of changes of capabilities. Do I have to set page_load_timeout and read_timeout separately now? and also I have read open_timeout, I don't know what it is for, Can someone help me understand what it is?

Drivers are not guaranteed to always return windows in the same order, so it has been decided to deprecate accessing windows based on their index (ie position in the Array of windows). You have a couple of options.
Working with 2 windows
If you are only working with 2 windows (probably most cases), the recommendation is to use 2 new methods:
# Switch to the second window that was opened
browser.switch_window
# Return to the first window
browser.original_window
Working with 3+ windows
The best approach would be to locate the window you want based on known properties:
# By url
browser.window(url: /closeable\.html/).use
# By title
browser.window(title: 'closeable window').use
# By an element in the window (new)
browser.window(element: browser.a(id: 'close')).use
(Not Recommended) By index
This is not recommended, but if you insist on using index, you can cheat by forcing the WindowsCollection to an Array:
browser.windows.each.to_a.last

Related

Can Core Data Become Corrupted?

Recently I implemented a new object type to be stored in Core Data. A very simply object: "LikedObjects" with one data type called
"likedObjects". Here is a snippet from my Xcode project.
For whatever reason, saving the data did not work. It would ALWAYS return nil (when before implementing this it worked perfectly for the other, crossed-out entities).
SOLUTION:
I deleted and re-installed the app. Works fine. Changed 0 code.
My question:
Is it possible / a way for CoreData to corrupt? I want to know a potential reason for why deleting and reinstalling the app was a solution, so that if so I can prevent this in any way...
Yes it can. One of the reasons could be a line separator coming from a Windows app (CRLF) or an otherwise invisible character within the XCode editor, coming from copy & paste.
One way to get rid of these problems is moving the file outside the project and then add it as an existing file once again. The import/copy function does a decent job of cleaning unwanted code. If this does not help, then you will have to write a function which purges ASCII characters 0-26, exception made for code 11 (LF). If you have binary data though, it may not work!
Finally, a matching pair of keys and values may have gone havoc. There, you will have to paste one by one (pair), until you find the cause of grief.

Object name becoming lowercase

I have some code which has worked in multiple installations for about a year. Today im doing a small change to a control and then another control seems to have developed an issue. When at runtime im getting a 91 error object variable or with block variable not set.
I therefore looked at the problem line which is: -
If Screen.ActiveForm.name = "frmFoutmelding" Then Exit Sub
so I noticed the name was lowercase. if i delete .name and rehit the "dot" then it shows me i can use .Name but as soon as i move from this line it drops back to .name
I've checked for instances of name and it appears everywhere in the code in different modules but i cant find if i have accidentally defined this lowercase name anywhere?
Googling doesn't seem to show much but i feel Im googling the wrong terms
chaps - thanks for your suggestions - this was the first instance of the lowercase name and searching as Jim suggested didn't reveal anything I'm afraid. What I did discover was that this was suddenly being run before any forms had actually been displayed and so the count was 0. I therefore, did an on error to check the form count and exit the sub if it =0 then if not to carry on with the line I thought I was having issues with.
It's likely that you did create a new variable or property called (lower case) name, or that some included reference did the same. It's possible to use reserved words as variable names in some cases, but it requires taking specific steps.
I would first search your code for instances of name As to see if you created a variable (this assumes you use Option Explicit, which is a must IMO). Then search for Property*name with * as a wildcard.
If those fail you could try unchecking references or components to see if any of them define name. If none of that finds anything, please post back here.
Jim Mack covers a lot of the potential issues. I think another is if you typed a lower case '.name' in association with Activeform at some point earlier in the same code module - the VB6 IDE checks in the current module and uses that to define what case to use. Look further up the same code module (sub or function).
Ultimately, check what changes you made by comparing the old source to the new in a file comparison tool like windiff - you do have backups, right?

Flex 4 Combo - using IME

I am trying to use ime (for hiragana input) in a flex 4 spark combo.
On creation complete I am setting the following.
cbx_text.textInput.imeMode = IMEConversionMode.JAPANESE_HIRAGANA;
And to check, tracing the following:
trace(cbx_text.textInput.enableIME); returns true;
trace(cbx_text.textInput.imeMode); returns JAPANESE_HIRAGANA;
However, when I select the text input and start to type some text I am unable to switch to hiragana.
I can set it to work on a textinput component with no problems.
<s:TextInput imeMode="JAPANESE_HIRAGANA"></s:TextInput>
Has anyone had any experience with this?
Any insights much appreciated.
Although I haven't had any experience with IME, I took a quick look at the documentation : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/IME.html
Can it be that it's not enabled application wise? That, maybe what returns true is only valid for the component you are tracing from?
Obvious questions first:
Are you certain the TextInput is a member of cbx_text? I know this seems silly, but it's best to eliminate the obvious first.
Do you have an IME enabled on your computer? For example, do you regularly type in hiragana on your computer and have the appropriate language pack enabled?
Are you sending the IME the string appropriately? IME.setCompositionString() for windows computers?
Does your OS support the use of IMEs? Linux only supports the following methods:
Capabilities.hasIME
IME.enabled <= Can set or return value.
Try tracing hasIME and see if it's installed. Again, we're shotgunning here – trying to track down any possibility of a problem.
When all else fails, go to the source:
http://livedocs.adobe.com/flex/3/html/help.html?content=18_Client_System_Environment_6.html

Abstract testing of GUIs

In general how does one test a various parts of a GUI? What are good practices? (Yes I am being overly general here).
Let take for Notepad's Find dialog box:
Notepad's Find dialog box http://img697.imageshack.us/img697/5483/imgp.png
What are some things that can be tested? How does one know its working correctly? What are edge cases to look out for? Stress tests?
Here.
I doubt any good generalization can be made about this - it always depends on the situation.
When someone asks for tests for GUI I always assume that that mean 'this part of application that is accessible via this GUI'. Otherwise it would mean testing the only the GUI without any logic hooked. Dunno why no one never actually asked for testing if the events are fired when button is pressed or is displayed window acquiring focus.
Anyway back to the question. First of all find out about equivalence classes, boundary conditions other testing techniques. Than try to apply it for given problem. Than try to be creative.
All those should be applied when creating following tests:
1) happy path tests - application acts right when given input is good
2) negative tests - application acts right when given input is bad
3) psychotic user behavior (I saw someone use this term, and I find it to be great) - that one user that has nothing better to do than break your application or is to stupid to actually know how bad and horrible things he is doing with your app.
After all this if all tests are passing and you can't figure out other, than you don't know is it working properly, but you can say that it passed all tests and it seems to be working correctly.
As for given GUI example.
1)
Is the application finding string that is in opened file?
Is the application finding character that is in opened file?
How is it reacting to reaching end of file during search?
Is it finding other appearances of given string/character or just one, when there are many of those appearances ?
Is it handling special search characters like * or ? correctly?
Is it searching in desired direction?
Is it 'Mach case ' option working properly?
When opening find setting some criteria, canceling search and launching it again - are search criteria back to default values? Or are they set as you left them when clicking Cancel?
2)
Is it informing user that no mach was found when trying to search for data that is not in opened file?
Is it reacting properly when trying to search down form end of file?
Is it reacting properly when trying to search up form beginning of file?
How search feature is reacting when no file is loaded? (in MS notepad it can be done, but in other editors you can launch editor without opening a file hence this test)
Can I mark both Up and Downs search direction?
3)
Is it working properly on 4GB file?
Can I load 4 GB string in 'Find What:' field and search for it?
Can I provide as input special characters by providing ASCII codes? (it was done like pressing Alt and number of character... or something like that)
Can I search for empty character (there was something like that in character table).
Can I search for characters like end of line or CarretReturn?
Will it search for characters form different languages? (Chinese, or other non-english alphabet characters)
Can I inject something like ') DROP ALL TABLES; (if that would be web based search).
Will I be able to launch proper event twice by really fast double click on search button? (easier on web apps)
With reasonable test suite you know it seems to work correctly.
I think it is better to separate out functional aspects and the usability aspects for the GUI testing.
Let us say in the above example take the use case of user entering some text and hitting the Find button. From the functional aspect I would say your tests should check whether this user action (event) calls the appropriate event handler methods. These can be automated if your code has good separation between the GUI display code and the
functional part.
Testing of usability aspect would involve checking things like whether the display occurs correctly in multiple platforms. I think this needs to be verified manually. But I think there are some tools that automate this kind of GUI testing as well but I've no experience with them.
It's difficult and error-prone to test finished UIs.
But if you are more interested form the programmer's perspective, please have a read of the paper The Humble Dialog. It presents an architecture for creating UIs whose functionality can be tested in code using standard testing frameworks.

General Purpose Filter As You Type (aka typeahead, Incremental find, autocomplete) is it out there?

Background
Lately I've become a fanatic that everything I type while working on a computer should be compatible with "DRY". If there's anything I have to type more than once in any context, I want some kind of user-aware auto-complete option to do some of the work for me -- always -- no exceptions.
Having to work under Windows, I've looked at GUI solutions to make this insane goal a reality.
The (almost) optimal solution
If you have a moment, open up Firefox 3.0 and type a few keystrokes into the address bar. You will notice that it performs a kind of Incremental Autocomplete based on space-separated sub-strings of whatever you type. Another place in Firefox that does something similar is the about:config URL.
This is sub-optimal, because I don't want this in Firefox only. I want to use this everywhere.
The Question
Does anyone out there know of a widget or app that does nothing but insanely good incremental auto-complete that can be used as a general purpose "run everywhere" tool? Something that allows the user to: 1) maintain one or more "completion candidate files"; 2) pick one of those files as the source for Firefox 3.0 style completion; 3) return the result (or blank if the user canceled), and do those three things only?
Details
Here's how it should work:
STEP1: user saves or more csv file(s) (or other easy-edit format) somewhere in his hard-drive
STEP2: user creates a Windows Script Host script or a batch file (or whatever) instantiates the FilterAsYouType GUI
STEP3: user runs the script file, and the script file instantiates the GUI, telling it which CSV file to use as the source of all potential completions
STEP4: the user either chooses one of the completions, supplies his own text that is not in the list, or cancels out without supplying anything
STEP5: when the user is done the script saves the result to a variable and does something with it
Here is some pseudo-code for the script:
include "GenericTypeaheadWidget";
var gengui = new GenericTypaheadWidget('c:\docs\favorite_foods.csv');
var fave_food = gengui.get_user_input();
if(fave_food != ''){
alert('you chose '+fave_food+'!');
}
The rationale
The goal is to just have a way to always be able to do auto-completions from a list of arbitrary items, even if the list is a couple thousand items, and not have to rely on it being built into some IDE or standalone application that only accepts certain kinds of input or has an overly-complicated API relative to the simplicity of this task.
CSV (or text or sqlite database) would provide a way for me to self-generate "candidate lists" or "history logs" and then just use those logs as the source of the possible completions.
The disclaimer
I've tried several GUI "launcher" programs, command-line engines like power-shell and scripting shells, the regular plain old command-line history with varying degrees of satisfaction. The problem with these is they all do extra superfluous stuff like searching directories or built-in commands. I just want nothing but whatever is in the CSV file I happen to be pointing at.
I'm wondering if there is any simple tool that does nothing but what I'm describing above.
UPDATE: It looks like this question is very closely related to Graphical Command Shell, which captures the essential idea presented here.
You should really try Launchy - it's exactly what you're looking for, a "run anything" with intelligent autocompletion. It completely changes the way you interact with a Windows PC.
And it has open source-code, so you can borrow its autocompletion code if you want to roll your own interface.

Resources