03.28.09

Git and Github on Mac

Posted in Software at 2:01 pm by Željko Filipin

Once upon a time, there was a tester. He knew his way around Ruby, Watir, SVN, Terminal and stuff like that. He heard people talk about Git, and he decided to try it. But Git was strange. He was playing with it a bit, but did not have much luck with setting it up, so he decided to leave it for later.

One day he decided to run his existing Watir tests on Internet Explorer 8 (IE8). He was already running them on IE6 and IE7, so he thought that it would be a piece of cake. He fired up one of his Windows virtual machines, installed IE8 and started the tests.

One of the first things he noticed is that file uploads were not working. File upload pop up would appear, but Watir was not populating it with path to the file that should be uploaded. He thought:

I think I know what is the problem. I have already heard that file uploads are not working if user has Windows language set to anything than English. It was something about the title of the pop up window.

And really, IE6 and IE7 had Choose file and IE8 had Choose File to Upload as pop up title.

IE6
ie6

IE7
ie7

IE8
ie8

He added C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.2 folder (that is where Watir lived on his Windows machine) to his Watir project in NetBeans, and made a search for Choose file. The search found 12 matches in 2 files. Both files were in watir-1.6.2\lib\watir folder. Files were input_elements.rb and winClicker.rb. He said (to himself):

I will try input_elements.rb first.

There he found an ugly long line that contained Choose file three times:

system("rubyw -e \"require 'win32ole'; @autoit=WIN32OLE.new('AutoItX3.Control'); waitresult=@autoit.WinWait 'Choose file', '', 15; sleep 1; if waitresult == 1\" -e \"@autoit.ControlSetText 'Choose file', '', 'Edit1', '#{setPath}'; @autoit.ControlSend 'Choose file', '', 'Button2', '{ENTER}';\" -e \"end\"")

He replaced all three occurrences of Choose file with Choose File to Upload.

system("rubyw -e \"require 'win32ole'; @autoit=WIN32OLE.new('AutoItX3.Control'); waitresult=@autoit.WinWait 'Choose File to Upload', '', 15; sleep 1; if waitresult == 1\" -e \"@autoit.ControlSetText 'Choose File to Upload', '', 'Edit1', '#{setPath}'; @autoit.ControlSend 'Choose File to Upload', '', 'Button2', '{ENTER}';\" -e \"end\"")

He tried file upload with Watir, and it worked! He was so proud, that he decided to share it with the world! Since Watir code recently moved from SVN to Git, it was also a perfect chance to try Git again. Watir code is hosted on Github, so he opened an account there.

pricing-github

He thought:

I will need to download the latest Watir code, make the change there and contribute back.

He found Watir repository and forked it. (It is polite to fork a repository on Github.)

fork1

He already had Git installed on his Mac. (Recently he became one of those cool people that use Macs.) He probably installed it a while ago when he tried Git for the first time.

He likes to have the newest versions of any software, so he updated Git.

Then he decided the time is right to download (or clone, as Git calls it) his fork of Watir. Do not make the same mistake he did! He cloned the repository using public clone URL (git://github.com/zeljkofilipin/watir.git). No, no and NO! You should use your clone URL (git@github.com:zeljkofilipin/watir.git) (He wants to say thanks to Bret Pettichord for teaching him that valuable lesson.) He found those links at Github after logging in and forking the Watir repository.

your-dashboard-github

zeljkofilipin_s-watir-at-master-github

But, before cloning he had to create SSH keys. He found the instructions at Github account page. There was a link with a friendly name: Need help with public keys?. Oh, he needed help!

He followed the instructions. Do not name your files github and github.pub, like he did. Leave default file names, otherwise it will not work. You do not need a passphrase for now. Leave it blank. (He wants to say thanks to Mislav Marohnić for teaching him all that SSH stuff.)


$ cd .ssh
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/zeljko/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/zeljko/.ssh/id_rsa.
Your public key has been saved in /Users/zeljko/.ssh/id_rsa.pub.

Now he had id_rsa and id_rsa.pub files. He gave contents of id_rsa.pub to Github. (You should keep your id_rsa as a secret. Never show it to anybody. Not even your best friend. Seriously.)

your-account-github

Now that chain of trust was made, he got the repository to his machine.

git clone git@github.com:zeljkofilipin/watir.git

He saw something like this:

$ git clone git@github.com:zeljkofilipin/watir.git
Initialized empty Git repository in /Users/zeljko/Documents/github/watir/.git/
The authenticity of host 'github.com (65.74.177.129)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,65.74.177.129' (RSA) to the list of known hosts.
remote: Counting objects: 13296, done.
remote: Compressing objects: 100% (4837/4837), done.
remote: Total 13296 (delta 8584), reused 11936 (delta 8216)
Receiving objects: 100% (13296/13296), 7.50 MiB | 549 KiB/s, done.
Resolving deltas: 100% (8584/8584), done.

He made the changes to the code with NetBeans. That was not such a good idea. But, I will talk about that later.

Then he committed the change to the local repository.

$ cd watir/
$ git add watir/lib/watir/input_elements.rb
$ git commit -m 'Fixed file uploads for IE8'

Finally, he pushed the change back to Github:

git push

He saw something like this:

$ git push
Counting objects: 11, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 530 bytes, done.
Total 6 (delta 5), reused 0 (delta 0)
To git@github.com:zeljkofilipin/watir.git
2a244f9..038e96b master -> master

In a blink of eye, he was already at Github looking proudly at his commit.

commit-038e96b52200a5d86b477654ef166c9a995ab9a7-to-zeljkofilipin_s-watir-github

But, he made one last mistake. (This is the last mistake. I promise. No more mistakes in this story. Enough is enough.) He did not know how to do a diff with Git, and NetBeans messed the whitespace, so his commit was a whitespace mess. Of course, he did not know how to undo. So, he just deleted his local and Github repositories and started over. (He had to wait a bit until he saw fork button again on Bret’s Watir repository.)

This time, he did everything right. After he pushed the change, he was so proud, that he decided to ask Bret Pettichord, the owner of the original Watir repository to merge his change with the original repository. That is called pull request.

commit-038e96b52200a5d86b477654ef166c9a995ab9a7-to-zeljkofilipin_s-watir-github-2

commit-038e96b52200a5d86b477654ef166c9a995ab9a7-to-zeljkofilipin_s-watir-github-1-1

Don’t just love happy ends?! :)

Update: Bret Pettichord points out that instead of deleting local and Github repositories after messing up the whitespace, our hero could undo the change with this:

git reset HEAD~
git push

03.17.09

Recording a Podcast with Skype on Mac Using Only Free Software

Posted in Free, Podcasts at 11:33 pm by Željko Filipin

I have a small podcast on Watir called Watir Podcast.

When I was recording podcasts on Windows XP machine, it was easy to do it using all open source or free software. All you had to do is install Skype (free, voice over Internet), Audacity (open source, audio recording and editing) and play a bit with Windows XP audio settings. To be true, it took me a few podcasts to figure out how to set audio just right, as you will surely notice if you listen to the first few of my podcasts.

A few months ago I got a Mac and I thought it would be as easy to record podcasts there. I was wrong. I have been trying and trying and only a few days ago I was able to record a Skype conversation on Mac.

What was the problem? I installed Skype and Audacity (both have Mac versions) and, to my great surprise, there was no option in Audacity to record both audio from Skype and from my microphone, as there is on Windows XP. I browsed around, tried a bunch of software and could not find anything that would work. At the moment, I think it is the limitation of sound card, but I could be wrong. (I used Boot Camp to install Windows XP on Mac, and could not record all audio even then.)

Then I found a great article, Recording Skype calls on GarageBand with LineIn and SoundFlower (Mac). It showed me that there is a way to record Skype on Mac using only free software. But it got me only 90% of the way. I was able to record both Skype and my audio, but I did not hear Skype audio. Asking a question and not being able to hear the answer is usually a problem in an interview. In the end, I found the solution in article’s comments, but it took me a while (and some luck) to figure out how to fix the problem.

So, how to record a Skype conversation?

Install Soundflower (open source), LineIn (free) and Skype (free).

To record and edit audio, you can use GarageBand (free, I got GarageBand ‘08 with Mac OS X, but you have to pay for GarageBand ‘09) or Audacity (open source).

System Preferences > Sound
– Output: Headphones – Built-in Audio (always use headphones when recording so your microphone does not catch sound from the speakers)
– Input: Internal microphone – Built-in (check ‘Use ambient noise reduction’ and move microphone input volume slider to the right)

sound

Skype > Preferences > Audio
- Audio output: Soundflower (2ch)
- Audio input: Soundflower (2ch)

audio

While configuring Skype for the first use, you should uncheck option that Skype automatically adjusts microphone volume and move the slider to the right, but I can not find that configuration wizard, even after reinstalling.

LineIn
Input from: Build-in Microphone: Internal microphone
Output to: Soundflower (2ch)

linein

GarageBand
Audio output: Built-in Output
Audio Input: Soundflower (2ch)

audio_midi

Create New Podcast Episode > Male/Female Voice > Monitor: On
Make sure you turn monitor “On”, or you will not hear the other person speaking. I heard my voice with about one second delay, so the next time I will try “On with Feedback Protection” instead of “On” setting.

1band

Audacity
Output: Core Audio: Built-in Output
Input: Core Audio: Soundflower (2ch)

audacity

Preferences > Audio I/O > Playthrough > Hardware Playthrough: Play new track while recording it > check
With software playthrough I heard my voice with about one second delay, but it was fine with hardware playthrough.

audacity-preferences

Start Skype conversation and when you want to record, click ‘Pass Thru’ button in LineIn and click record button in GarageBand or Audacity.

Software versions I used:
Mac OS X 10.5.6.
Soundflower 1.4.3
LineIn 2.0.3
GarageBand ‘08 4.1.2 (248.7)
Audacity 1.3.7
Skype 2.8.0.324

01.24.09

AWTA 2009 Notes

Posted in Events, Watir at 5:17 pm by Željko Filipin

AWTA 2009 Saturday

AWTA 2009 was a lot of fun. At Notes from AWTA 2009 you can find a lot of images, notes, podcasts, blog posts, presentations, twitter feed…

It was great to finally meet in person a lot of people I knew on-line for years. I have learned a lot how other people test. Also, Austin and Texas were very interesting to explore. I think all is already said about AWTA 2009. I just hope I will be there the next year too.

AWTA 2009 Sunday

« Previous entries Next Page » Next Page »