akephalos icon indicating copy to clipboard operation
akephalos copied to clipboard

HtmlUnit Type Error: Cannot find function

Open maca opened this issue 13 years ago • 12 comments

Hi, I am trying to test Facebook connect integration with my app, I can login to facebook, and executing some javascript unauthorize my app for testing authorization. Shit happens when through akephalos I visit facebook authorizatation page and I press Allow, then I get this message:

       com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find function parse in object [object Window]. (script in http://www.facebook.com/connect/uiserver.php?method=permissions.request&app_id=143526625701274&display=page&redirect_uri=http%3A%2F%2Fboston-test.com%2Fauthentication%2Ffacebook&type=web_server&fbconnect=1&perms=email%2Cpublish_stream&from_login=1 

here's a gist on how the error can be reproduced:

https://gist.github.com/799148

I googled about this and some posts suggest changing html unit browser emulation to IE7,

does akephalos provides an option for doing so?

maca avatar Jan 27 '11 20:01 maca

Can you try using this repo please:

gem 'akephalos', :git => "[email protected]:Nerian/akephalos.git"

Nerian avatar Jan 29 '11 23:01 Nerian

Nerian, thanks. I've tried using your repo but when using it to running my features it won't rely on the akephalos driver but the rack test one. Meaning webrick is not launched and any visit that involves going out of my app won't work.

maca avatar Feb 02 '11 00:02 maca

Do you have this? Capybara.default_driver = :akephalos

Nerian avatar Feb 02 '11 00:02 Nerian

Yeah, I do, I could run my features with akephalos prior to adding your repo to my Gemfile.

maca avatar Feb 02 '11 01:02 maca

BTW, I am not using Rails but Sinatra.

maca avatar Feb 02 '11 01:02 maca

I tried something. Tell if it works: https://github.com/Nerian/akephalos/tree/emulation-ie7

gem 'akephalos', :git => "git://github.com/Nerian/akephalos.git", :branch=>"emulation-ie7"

Nerian avatar Feb 02 '11 02:02 Nerian

Mmm nah, it fails. Let me rethink.

Nerian avatar Feb 02 '11 02:02 Nerian

Ok, I did set html unit browser emulation to IE7. Check if your test works now.

gem 'akephalos', :git => "git://github.com/Nerian/akephalos.git", :branch=>"emulation-ie7"

Nerian avatar Feb 02 '11 02:02 Nerian

Still no luck, I guess web server is getting launched because it takes longer to start but I get no feedback, I don't know if starts on the same port. I have edited my hosts file to have a dummy domain pointing to localhost and I setted an Nginx virtual host as a proxy for that domain into the port 9887 which is the one used by akephalos, all this because to test Facebook integration I need to provide a domain. Anyway when I try to see what akephalos is getting I get a bad gateway which makes me believe akephalos is not launching a web server or it is launching it in another port.

maca avatar Feb 02 '11 03:02 maca

Setting client.setThrowExceptionOnScriptError(false) as here solved the issue.

https://github.com/windock/akephalos/commit/bb56c7575a515f8b878c7513b608788b23c7ee58

maca avatar Feb 02 '11 03:02 maca

That's weird, that code it is actually in my that too.

Nerian avatar Feb 02 '11 12:02 Nerian

(3 years later)

This solved my problem too. My "missing" function was document.getElementsByClassName, which doesn't make much sense.

ashes999 avatar Nov 06 '13 03:11 ashes999