XAML Spy Setup Wizard ended prematurely [Solved]

August 5, 2013

I use XAML Spy and like it. It has monthly update releases. When I tried to install the July update, the setup ended with the message:

XAML Spy Setup Wizard ended prematurely

 

I couldn’t find anyone talking about it on the net, but searching for “setup wizard ended prematurely” led me to this MSDN forum question, which gave me the idea to run msiexec with logs – msiexec /i <path_to_msi> /L*V <path_to_log>

Once I did it and inspected the generated log, I noticed that the installation failed when trying to set firewall exception (ExecFirewallExceptions:  Error 0x800706d9). A quick check revealed that my Windows Firewall service was disabled – I have no idea why. I enabled it and started it and run the XAML Spy setup again, and this time it run successfully to the end.

I hope this might be useful to anyone else running into the same problem and searching for a solution. Maybe XAML Spy developers will also read it and improve the installation to give better error message in such case.

Edit: This is now added to the XAML Spy troubleshooting page.

UAC: Elevated process doesn’t inherit its parent’s working directory

March 1, 2009

One of the first things we do in the installation that our internal install framework generates is to elevate the user in case we run on Windows Vista or Windows Server 2008.

The way to do it is a common knowledge – in a VBScript file, start your process with ShellExecute and pass the “RunAs” parameter.

However, we had at least two problems with it, which were due to the fact that our install scripts assumed their working directory is the directory they reside in. While this was correct in a non-elevated environment (e.g. on Windows XP/2003), it turns out that when ShellExecute starts an elevated process, the elevated process does not inherit the working directory from the calling process, but instead, its working directory is initialized to the system directory.

I didn’t see this mentioned in any of the places that explain how to elevate a process, so I thought it will be good to at least post it here.

After I wrote this, I saw that Raymond Chen wrote that this was done in order to avoid certain security attacks. See also this post by Chris Jackson where he explains that elevated process doesn’t get the environment variables of the process that started it because it is not the real child process of the elevating process. He then adds in a reply to a commenter that the working directory is another story.

Total Commander (obsolete) tip: How to open a zip file with a non-zip file extension like JAR, XPI or EXE

February 25, 2009

Total Commander (TC) has a feature called “packing”, which is actually built-in support for zip files that allows you to easily double-click a zip file and open it as if it was a folder – navigate zipped folders hierarchy, copy/move files and folders from it or open/edit/view files in it.

This is very handy, but often, I have to deal with zip files with other non-zip extensions, where double-clicking them opens them with another application, but I want to inspect their zipped content within Total Commander as if they had a zip extension. Three common samples for such files are XPI files used to package and install Firefox extensions, JAR files and EXE files which are actually self-extracting zip files. I’m currently working on two internal install frameworks. One of them generates a Setup.jar install file, and the other one, one run on Windows, generates a self-extracting exe using WinRAR.

In these three samples, when I want to view the zipped file content, I used to be forced to either open the file with 7-zip, or renaming the file to have a zip extension and open it in Total Commander.

Recently, I found out that there is a better way to handle this in Total Commander 7.

A few weeks ago I discovered that if I try to change the current directory of a Total Commander panel to a file and not a directory, Total Commander changes the directory to the directory of that file, and then selects the file, which is a handy feature of its own. However, if this file is a zip file, then Total Commander will not select the file, but instead, it will open it as a zip file. The good news is that this is true for all zip files, even those with other extensions like EXE, JAR or XPI.

Note that this only works with Total Commander 7 and not in earlier versions. Also note that this magic only occurs if you change the directory of the panel to the full absolute path of the zip file. Using a partial relative path won’t work, and Total Commander will not change the directory.

On my machine, where Total Commander is configured to have Ctrl-G start editing the panel path and Ctrl-P copies the full path of the selected file(s), I can easily select a zip file and type Ctrl-P, Ctrl-G, Enter to browse the file zipped content, but on other machine that doesn’t have this keyboard remapping, I’m using the following sequence:

  1. <Right Arrow> – to show the TC command line in case it is hidden (it is hidden on my machine)
  2. type cd
  3. <Space>
  4. <Ctrl-Shift-Enter> – to copy the full path of the selected file to the command line. This is a standard TC keyboard shortcut.
  5. <Enter> – to invoke the magic

I added “(obsolete)” to this post subject because after writing all of this, I went over the post draft to add links to the relevant words, and when I looked for a link that explains Total Commander support for zip files, I found these two FAQs about how to open JAR files and how to open self-extracting archives and realized that TC has a built-in support for handling this problem – using Ctrl-PageDown, so my tricks are pretty much obsolete. However, I thought this still deserves publishing, as it might reveal new features for TC users who read this.

How to write a ruby function that can accept either a string or a regular expression

July 30, 2008

While working on our unit test framework, I wanted to write a function that checks if a given Ext JS windoid is opened. The function should accept a title argument. This was easily implemented as:

	# title is a string with the exact windoid title
	def windoidDisplayed?(title)
		spans = $browser.spans
		t = $browser.length && $browser.detect {|i| \
			i.class_name == 'x-window-header-text' \
			&& title == i.text \
		}
		return t && t.visible?
	end

I then realized that users might not have the full title of the window, and might only want to check for a windoid with a title that matches some regular expression. A simple and naive way to do it is

	# title can be a string or a regular expression
	def windoidDisplayed?(title)
		spans = $browser.spans
		t = $browser.length && $browser.detect {|i| \
			i.class_name == 'x-window-header-text' \
				&& (title.kind_of?(String) \
					? (title == i.text) \
					: (title =~ i.text)) \
		}
		return t && t.visible?
	end

However, I didn’t want to check in every loop iteration if the passed title argument is regular expression. Although performance is really a non-issue in our unit tests, it just seemed to be a cumbersome and ugly code. I thought of using the dynamic nature of ruby to add a method (e.g. “match?”) to both string and regular expression classes, so I can call it in a polymorphic way without having to detect the type of title:

	class String
		def match?(x)
			return self == x
		end
	end
	
	class Regexp
		def match?(x)
			return self.match(x)
		end
	end
	
	# title can be a string or a regular expression
	def windoidDisplayed?(title)
		spans = $browser.spans
		t = $browser.length && $browser.detect {|i| \
				i.class_name == 'x-window-header-text' \
				&& title.match?(i.text) \
		}
	return t && t.visible?

Before implementing it, I thought I’d check if a similar function already exists in Ruby’s Standard Library, and indeed, when I looked up the Ruby book for functions that are in both String and Regexp classes, I run into “===” (the Case Equality operator), which is meant exactly for this kind of things. Unlike JavaScript, where the === operator is meant for identity, in Ruby, the === method is usually called in case expressions to match the case target for each when clause. As said in the documentation, for the String class, === method tests for equality and is the same as ==, but for Regexp class, === method tests for matches, and is the same as =~. Exactly what I was looking for. So my little function can simply be implemented like:

	# title can be a string or a regular expression
	def windoidDisplayed?(title)
		spans = $browser.spans
		t = $browser.length && $browser.detect {|i| \
				i.class_name == 'x-window-header-text' \
				&& title === i.text \
		}
		return t && t.visible?
	end

BTW, while searching for that, I took a look at Watir‘s sources, hoping to learn from the experts as I’m new to Ruby.
I found that Watir source (watir.rb, lines 50-70) does a similar trick to what I initially thought to do – define a new “matches” method (and not “match?” like the ruby convention that is also used in Watir in methods like “exists?” and “visible?“), and don’t use the === method.
In addition, in several places in the code there are still explicit tests for String class, such as the verify_contains method in input_elements.rb and navigate_to_link_with_id and navigate_to_link_with_url methods in watir_simple.rb.

Handling browser on test start and end

July 23, 2008

When I started building a unit tests framework for our product, I decided that I want the browser to remain open through all tests, and only be closed at the end. This is because I don’t want a developer running these tests on his machine to be disturbed with many browser windows opened and closed.

However, as I quickly found out, there is no easy way to run code at the beginning and end of a test suite. This seems to be intentional, as each test case should be separate and independent of other tests in the suite. The setup and teardown methods are run for each test case.

One simple solution was to drop it and simply start the browser on every test case and close it on end, but when I played with it a little more, I reached an even better solution. I’m starting the browser at the beginning of the test and assign it to a global $browser. Then, if the test fail (which can be detected by @test_passed), we set $browser to nil, so the browser window remains, and subsequent tests create and use a new browser window. If the test succeed, the browser window is reused through $browser. At the end of the test, we close the browser if $browser is not nil. With this constellation, after the test suite finishes running, we have a browser open for each failed test, so we can inspect what went wrong and how the application looks at the time of the fail.

Here is the code I used to implement it:

# cleanup on close
END { # close browser at completion of the tests
$browser.close if $browser && $browser.exists? && !ENV[‘DONT_CLOSE_BROWSER_AT_END’]
Watir::IE.quit
}

module MyTestSuite < Watir::TestCase ############################################################# # setup method: # This setup function is called by the UnitTest framework before any test is run. # The function initialize the global $browser object if needed ############################################################# def setup return if $browser $browser = Watir::IE.new $browser.speed = :fast $browser.add_checker(PageCheckers::NAVIGATION_CHECKER) $browser.maximize unless ENV['DO_NOT_MAXIMIZE_BROWSER'] end ############################################################# # teardown method: # This teardown function is called by the UnitTest framework after any test is run. # The function reset the global $browser object in case an error # occurred (unless NO_NEW_BROWSER_ON_ERROR), so # a new browser window will be created in case an error occurred. ############################################################# def teardown $browser = nil unless @test_passed || ENV['NO_NEW_BROWSER_ON_ERROR'] end # ... test cases methods goes here end [/sourcecode]

Watir – first impressions

June 24, 2008

Our product doesn’t have unit tests. There, I said it. For a long time I’ve been looking for a way to build unit tests. There are three factors that prevented me to do so until now:

  1. It seems not to be really needed. When testing is needed, developers go over an installation and check that everything is working. Building a suite of tests to test all possible scenarios seems to be a huge task that doesn’t worth the effort.
  2. This is a web application that is constantly changing, so it seems hard to write robust test that will not break on every change. In addition, it uses a session ID that is passed in the URL, so URLs are different on every run.
  3. The data keeps changing. Our data is on the mainframe, and it is owned and used by other teams so we can’t expect to have the same data all the time, which makes it problematic to build solid tests.

In the past I tried using Selenium, but never really fell in love with it, and never got the time to deeply look into it and test it.
Recently I saw Ofer’s post about Watir and decided to take a better look at it and see if we can use it. Since I’m fluent at Javascript, and had a recent experience with Perl working on an installation automation project for a few months, catching Ruby was quite easy. As Ofer observed, Ruby seems to be a really nice language, but I have some problems adapting to Watir. For example, it took me sometime to understand how Javascript code can be invoked from Watir, but now I know it is done using:

$browser.ie.Document.parentWindow.execScript(js_expression)

At first, since I come from normal OO languages, I thought of creating a base ProductUnitTest class that derives from Watir::TestCase, and then, for each version or fix pack, we will create a VersionXXUnitTest class that will derive from ProductUnitTest. However, this doesn’t work well, since Test::Unit looks for all the included classes that derived from Test::Unit::TestCase, and since we would have to require ProductUnitTest in order to derived from it, Test::Unit will see two such class and will run the tests in ProductUnitTest twice – once for ProductUnitTest, and once for the derived VersionXXUnitTest.

Checking further, I came to the idea I have to use Ruby’s mixins, which is somewhat similar to Java’s interfaces, but more comfortable and easy to use, since Ruby is a dynamic language. So now, I define all basic tests and helper methods (like setup and teardown – see next post for more details on this) in a module named ProductUnitTest, and then, for each version, I define a VersionXXUnitTest class that derive from Watir::TestCase, and then includes ProductUnitTest so all the tests (and helper methods) are there, but only invoked once, for VersionXXUnitTest.

To conclude, Watir seems like a very nice framework to test our web application, and this will probably solve problem #2 above. I plan to broaden its use when we start building our next fix pack, where we have specific things we need to fix, and whenever we fix something, we should write a unit test for it right away. This is easier then writing and maintaining unit tests for an entirely new version that keeps changing. I hope that once our developers get used to it and see how it can help integration and acceptance tests they will see its value and overcome problem #1 above. I still need to find a good way to bypass problem #3.

I already showed what I did to Amit from QA, and she really liked it and said it might be useful for them as well.

P.S.
Another nice benefit of learning Ruby is that now I better understand some of the design made by the Prototype team members, which were clearly thinking in Ruby, as they are using Ruby on Rails.

Macro to add a hyperlink to a mail message

February 13, 2008

Today I wrote a mail to someone and wanted to add several links. It always annoyed me that Office’s Add Hyperlink is so bloated it takes some time to open, and even more time to switch back to it from another application, where all I wanted was to make the selected text link to the URL I had in my clipboard. So I set out to write a macro that did it.

Since Outlook has no macro recorder, I started searching Outlook’s Object Browser and discovered that there is no method to add a hyperlink or to get the content of the clipboard. So I borrowed the “Getting clipboard content” functionality from a VBS script I already had, and I turned to Word to record a macro that adds a hyperlink to the selected text. Once I had this Word macro, I found out I can use ActiveInspector.WordEditor to issue the Word macro I created.

The final macro result is this:

Public Sub AddLinkFromClipboard()
    If ActiveInspector.EditorType = olEditorText Then
        MsgBox "Can't add links to textual mail"
        Exit Sub
    End If
    Dim objHTM As Object
    Dim ClipboardData As String
    Dim doc As Object
    Dim sel As Object
    Set objHTM = CreateObject("htmlfile")
    ClipboardData = objHTM.ParentWindow.ClipboardData.GetData("text")
    Set doc = ActiveInspector.WordEditor
    Set sel = doc.Application.Selection
    doc.Hyperlinks.Add Anchor:=sel.Range, _
        Address:=ClipboardData, _
        SubAddress:="", _
        ScreenTip:="", _
        TextToDisplay:=sel.Text
End Sub

Xobni feedback: Missing tooltips

January 16, 2008

In various areas in the sidebar, when there is not enough space for a string, ellipsis is used, but when I hover over it with my mouse, I expect to see a tooltip showing me the entire string, so I don’t have to make room for it to see what the string is. This is common UI pattern, which is missing in Xobni.

Sample for such problems can be see in panes titles (such as “People connected to…”, “Conversation with…”), messages subjects and some more.

Xobni makes excessive use of “what’s this” tooltips at the upper part of the sidebar, explaining each of the items, and also when the links for a person (“schedule time with…”, “e-mail…”) are truncated in a narrow sidebar, the tooltip shows their full text, but that’s less important. The count in the end of a pane title, or a message’s full subject is much more important, and for this, Xobni fail to show tooltips.

Xobni feedback: Limited contact information

January 16, 2008

Xobni will only let you store one phone number per person. But what if someone has a work number, home number and a cell phone, and you decide what to use based of his daily schedule and the time of the day?

It would be very convenient to be able to assign several number to a person, and then, when this person is displayed in the Xobni side bar, all his numbers would be displayed, and you could choose what to use.

Another problem with person contact is that when you edit it and add a number, you loose the information Xobni collected from e-mails, so if you added a picture for a person, or mistakenly set a phone number for him, you have no way to ask Xobni to use the person contact details it gathered from e-mails.

There should be an option to tell Xobni to revert back to use data from e-mails, and also there should be a way to edit this information or to add data like picture without affecting this information.

Xobni feedback: Missing right-click menus

January 16, 2008

Although they bragged about adding right-click menu to the sidebar, I still miss having all the options from the relevant Outlook menu when I right click a message, a contact or an attachment.

For example –

  • If I see an attachment in the Xobni bottom panel, I’d like to be able to save it to a file.
  • If I see someone name in the people pane, I’d like to be able to open it’s related Outlook contact.
  • If I see a message I’d like to be able to move it to a different folder (and also to know what folder it is currently in, but this is something for a separate post…)