Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma fails to capture IE when run from OSX through VMWare Fusion #4

Open
bitwiseman opened this issue Jul 8, 2013 · 8 comments
Open

Comments

@bitwiseman
Copy link

(similar repro steps to #3 ).

Repro:

  1. On OSX install VMWare Fusion
  2. Clean Install Windows VM in Fusion mode (so that windows apps appear to run on OSX desktop.
  3. Open OSX console window
  4. Install node.js 0.10.12
  5. npm install karma
  6. npm install karma-ie-launcher
  7. Figure out what command-line to will launch IE from OSX console via VMWare Fusion (@bitwiseman have never tried this).
  8. Change karma.conf.js to run IE in single-run mode
  9. karma start karma.conf.js

Expected:
karma to launch and capture IE, run tests, exit and close IE

Actual:
karma launches IE three times and believes IE has exited each time.

Windows version can be 32-bit or 64-bit, can be window xp or greater.

@bitwiseman
Copy link
Author

Moving discussion from #3:

@pouncilt said:

Well I am having the same capturing problem; but I am using VMWare Fusion to launch IE from my mac. I added the > http://localhost into my intranet zone for IE, and turned protected mode off in IE. The one good thing that came from
doing this is now Karma only launches IE once instead of 3 or more times. Karma is able to run my test before
crashing.

Setting the IE_BIN variable doesn't help me because IE is not on my local file system; but rather on my virtual
machine. How do I get Karma to stop crashing when I test IE in a virtual machine? I wonder how might I solve this
problem? Any ideas?
BTW: my virtual machine is running Windows 7 32-bit OS and IE8.

@bitwiseman
Copy link
Author

@pouncilt - What you're describing sounds like a very odd usage scenario. If you're trying to launch IE on a windows vm from an instance of Karma running on the host mac system, there is going to be some interesting acrobatics occurring to make this happen.

Are you running Karma from a windows cmd shell?
Have you tried this in non-Fusion mode running Karma inside the windows VM?

@bitwiseman
Copy link
Author

@pouncilt said:

@bitwiseman - I am running Karma from my mac terminal.

As you may or may not now already is that macs can not run an IE browser so that is why I am using vmware fusion;
so I can use IE from my mac.

I am curious to know if you get the same error message as I do: ERROR [launcher]: [BROWSER NAME HERE]
crashed? In my case the actual error message is: ERROR [launcher]: src/test/scripts/ie8.sh crashed.

This might be the same issue, if you get the same message; because I cannot set the IE_BIN variable Karma
doesn't know the correct IE path.

@bitwiseman
Copy link
Author

@pouncilt -
(Feel free to delete you response from the other issue (as I did with mine).
I understand what VMWare Fusion is, I often run on a mac as well, but I do not run in Fusion mode - I like my Windows VM to be all in one window.

You are correct, this issue is similar #3, but these really are different issues.

The root cause for the other issue is a combination of running on widows 8 64-bit and karma trying to launch 32-bit IE.
The root cause for this issue is running karma from a mac console to launch IE using VMWare Fusion.

Because of this, the workaround listed in the other issue will not fix this issue. My best guess at a workaround for this issue is completely different from #3.

Please try the following:

  1. If IE_BIN is set, clear it.
  2. Install node.js for Windows VM ( from http://nodejs.org/dist/v0.10.12/node-v0.10.12-x86.msi , for example).
  3. From mac console launch cmd.exe window.
  4. (In cmd window) node --version - should show "v0.10.12"
  5. (cmd) mkdir karma-test; cd karma-test
  6. Copy your project from your mac folder to the windows-side karma-test folder
  7. (cmd) npm install
  8. (cmd) Do whatever remaining steps you do to run karma - but only use the cmd window to do them. In particular, be sure that that your call to karma start is done from the cmd window.

I believe this will work (assuming your project can run on windows), but it may not. Please tell me your results.

@tonte-pouncil
Copy link

The original scripts that was used to get all this working can be found here: https://github.com/angular/ci.angularjs.org/tree/master/bin. I downloaded the ie8.sh and i.e_.sh files. I ran into problems running the ie8.sh because it could not resolve the location to the i.e_sh file via the ". i.e_.sh" at the end of the file. So I added the absolute directory in front of the i.e_.sh file name and I renamed the i.e_.sh file to i.e.sh and I updated the ie8.sh file to:
[Start of the ie8.sh file]
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

VMNAME="Win7_IE8"
VMPATH="/Users/pouncilt/documents/Virtual Machines.localized/Win7_IE8.vmwarevm/Win7_IE8.vmx"
LOG_FILE="/Users/pouncilt/Development/software/virtual-machine/ie8.log"

. $DIR/ie.sh
[End of ie8.sh file]

[Start of i.e_.sh file]
#!/bin/bash

export PATH="/Applications/VMware Fusion.app/Contents/Library/":$PATH

winExec() {
if [[ "$VMPATH" == XP ]]; then
vmrun -T fusion -gu misko -gp heslo runScriptInGuest "$VMPATH" "" "cmd.exe /c "$1" $2 $3 $4" >> $LOG_FILE 2>&1
else
vmrun -T fusion -gu misko -gp heslo runProgramInGuest "$VMPATH" -activeWindow -interactive "$1" $2 $3 $4 >> $LOG_FILE 2>&1
fi
}

killIe() {
winExec C:\Windows\system32\taskkill.exe /IM iexplore.exe /F
}

trap "killIe; exit 0" EXIT

echo -e "\n\n\n----------------+ date +----------------\n" >> $LOG_FILE

captureUrl=$1
winExec "C:\Program Files\Internet Explorer\iexplore.exe" ${captureUrl/localhost/[YOUR MAC IP ADDRESS HERE]}
[End of i.e_.sh]

Here are the steps to install and run IE8 from mac:

  1. I have using Fusion 5.0.4 running on my mac book pro.
  2. I have Download Internet Explorer Application Compatibility VPC Image from Official Microsoft Download Center.
  3. I downloaded the Windows_7_IE8.part01.exe, Windows_7_IE8.part02.rar, Windows_7_IE8.part03.rar, and Windows_7_IE8.part04.rar
  4. I used a windows laptop to run the exe and create the Win7_IE8.vhd and Win7_IE8.vmc files.
  5. I copied these files to my mac book pro.
  6. I imported the Win7_IE8.vhd file into Fusion; which created the Win7_IE8.vmdk file.
  7. I created a new virtual machine with the newly created Win7_IE8.vmdk file by making a separate copy of the virtual disk.
  8. Start the Win7_IE8 vm and login as IEUser. The password is "Password1".
  9. I installed the VMWare Tools.
  10. I configured the ie8.sh script as a browser inside the karma.conf.js file like so: browsers = ['src/test/scripts/ie8.sh'];
  11. I configured the Karma server for continuous integration mode by setting singleRun to false.
  12. I ran the Karma server to capture the IE8 browser.
  13. Unfortunately for me, the wrong Karma URL (http://%22http//[YOUR MAC IP ADDRESS HERE]:9876) was enter into the IE8 browser and I had to do a work around.
  14. First I updated the i.e.sh file to:
    [Start of i.e.sh file]
    #!/bin/bash

export PATH="/Applications/VMware Fusion.app/Contents/Library/":$PATH

winExec() {
if [[ "$VMPATH" == XP ]]; then
vmrun -T fusion -gu IEUser -gp Password1 runScriptInGuest "$VMPATH" "" "cmd.exe /c "$1" $2 $3 $4" >> $LOG_FILE 2>&1
else
vmrun -T fusion -gu IEUser -gp Password1 runScriptInGuest "$VMPATH" -activeWindow -interactive "" "cscript.exe "$1" $2" >> $LOG_FILE 2>&1
fi
sleep 3
}

winExecute() {
if [[ "$VMPATH" == XP ]]; then
vmrun -T fusion -gu IEUser -gp Password1 runScriptInGuest "$VMPATH" "" "cmd.exe /c "$1" $2 $3 $4" >> $LOG_FILE 2>&1
else
vmrun -T fusion -gu IEUser -gp Password1 runProgramInGuest "$VMPATH" -activeWindow -interactive "$1" $2 $3 $4 >> $LOG_FILE 2>&1
fi
}

killIe() {
winExecute C:\Windows\system32\taskkill.exe /IM iexplore.exe /F
}

trap "killIe; exit 0" EXIT

echo -e "\n\n\n----------------+ date +----------------\n" >> $LOG_FILE

captureUrl=$1

#winExecute "C:\Program Files\Internet Explorer\iexplore.exe" ${captureUrl/localhost/[Mac IP Address Here]}
winExec "C:\Users\IEUser\startie.vbs" ${captureUrl/localhost/[Mac IP Address Here]}

  1. I then had to create a vbscript named startie.vbs to get the correct Karma URL into IE8 browser.
    [Start of startie.vbs file]
    Dim strIE
    Dim objArgs
    strIE = "C:\Progra1\Intern1\iexplore.exe"
    Set objArgs = Wscript.Arguments
    Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run strIE & " " & objArgs(0)
[End of startie.vbs file]
116. Now I am able to run Karma server and have it start IE8 browser with the correct Karma URL and run all my tests successfully in IE8 before it Karma reports the following error: ERROR [launcher]: src/test/scripts/ie8.sh crashed.

So I don't know why Karma keeps crashing. Any help to resolve this would be deeply appreciated.

Thank you.

@bitwiseman
Copy link
Author

Thanks.
It looks like the ie_.sh should be creating a log file. If so, what's in that log file?

In your last step you said, that IE8 launches and runs all your tests and then reports a crash at the end of the the run. Did I read that correctly?

In your first update of ie_.sh to ie.sh, I understand your change. I'm not sure I understand the second one. I see you needed to change the IP address, but you made further modifications by adding winExecute() and running through that sometimes. ... I see there was a %22 being added which translates to a " being added at the front of the URL.

What about the work around steps I suggested? I know they are not a viable option long term, but then you would at least have runable state while we figure this out.

@tonte-pouncil
Copy link

The VMWare Fusion logs go in there. For example if you have the wrong user name and password, VMWare Fusion will log this error in the log file. Or if you try to start Karma before you start VMWare Fusion, VMWare Fusion will tell you that the VM has not been started.

Yes, you read me correctly - IE8 successfully launches and runs all my Jasmine test successfully and then Karma crashes once all the test have rand. When you start Karma in continuous integration mode it is supposed to stay running and connected to the browsers, and re-run the Jasmine tests if and when the code changes.

WinExecute() method is actually the original method. The only thing that is different from the original method is the name "winExecute()". I needed to keep the original winExecute() method in order to properly kill the browsers regardless if the browsers are running on VM or locally and whether or not the browsers are IE, FF, Chrome, or Safari. You will notice that the winExecute() method is only called from the killIe() method. In addition to this, you should notice that I changed the winExec() method in the else block to run the csscript.exe and that this winExec() method is only called at the end of the script; which is where I pass in the VBscript and Karma URL.

In addition to seeing that the %22 being added to the beginning of the URL, you should also see an actual double quote at the of the URL. At least, that is what I am seeing.

I didn't try the work around you suggest because I am able to start the IE8 browser in the VM and run my tests. Until this issue is resolved, I will just have to keep killing Karma server after each test run because Karma thinks that the browser has crashed. In reality the browser doesn't really crash. The script receives an exit 0 code and calls the killIe() method. If I comment out the trap statement the browser would still be open.

I am glad that you are taking a look at this. I really appreciate this. Let me know if you were able to follow my steps to reproduce this issue. If you are able to reproduce, are you seeing the same things I am seeing? You can get a 30 day trail version of VMWare Fusion to test with.

Thank you.

christophercurrie pushed a commit to christophercurrie/karma-ie-launcher that referenced this issue Jan 22, 2014
This patch tries to auto-detect 64-bit IE by checking
for the appropriate environment variables. It also
improves reliability of the tests by disabling
extensions and using "InPrivate" mode to ignore
existing user data. Addresses karma-runner#1, karma-runner#2, karma-runner#4, and possibly karma-runner#8.
@vojtajina
Copy link
Contributor

Can anybody double-check whether this issue is fixed in 0.1.2 please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants