akephalos
akephalos copied to clipboard
Akephalos not picking up on select element that has been enabled via JS
I have a select element that is disabled by default on the page. Clicking a checkbox will enable this select menu to be used with the following Javascript...
$('#checkbox_element_id').live('change',function(){
var dropdown = $('#select_element_id');
if( dropdown.attr('disabled') ){
$(dropdown).attr('disabled',false);
} else {
$(dropdown).attr('disabled',true);
}
} );
Selenium picks up on this change, while Akephalos does not. I'll try and think of ideas for a fix once I've had a chance to go through the source, just wanted to make this known.
thinking about this now, maybe akephalos does not like how jquery's live events function?
I'll take a look into this, but it is likely a problem with the live call -- HtmlUnit has a few known issues regarding live events.
May be something other than the .live() call - I have a function that runs in $(document).onready() that marks a button as disabled, but Akephalos (HTMLunit) isn't seeing that, either - code snips: https://gist.github.com/d5ffd91c2362d871b587
I have a similar problem but this time with a click event triggered on a button tag. In selenium works just fine, but it doesn't seem to work with akephalos.
The javascript code I'm trying to execute is the following:
$(document).ready(function(){
$("button[type='button']").bind('click', function(ev){
ev.preventDefault();
toggle_user($(this));
});
});
Any ideas why this won't work? BTW, I'm using:
akephalos (0.2.5) capybara (0.4.1.2) celerity (0.8.8) culerity (0.2.15) steak (1.1.0) rspec (2.5.0) rails (3.0.4) ruby (1.9.2)
Update: The error is on executing:
click_button "Remove"
page.should have_content("Add")
I get:
Failure/Error: page.should have_content("Add")
expected #has_content?("Add") to return true, got false
# ./spec/acceptance/group_spec.rb:132:in `block (5 levels) in <top (required)>'
# ./spec/acceptance/group_spec.rb:130:in `block (4 levels) in <top (required)>'
I have a similar problem like damselem, on a link tag without using live:
$('#us_user_session_new_button').click( function() {
$('#us_user_session_new').submit();
return false;
});
<a id="us_user_session_new_button" href="#" class="large primary button">Sign In</a>
Clicking the link via click_link('us_user_session_new_button') results in this output, notice the form is never submitted:
2011/05/24 17:59:29:660 PDT [DEBUG] HtmlElement - Firing Event mouseup (Current Target: HTMLElement for HtmlAnchor[<a id="us_user_session_new_button" href="#" class="large primary button">]);
2011/05/24 17:59:29:661 PDT [DEBUG] HtmlElement - Firing Event click (Current Target: HTMLElement for HtmlAnchor[<a id="us_user_session_new_button" href="#" class="large primary button">]);
2011/05/24 17:59:30:210 PDT [DEBUG] HtmlAnchor - do click action in window '', using href '#'
2011/05/24 17:59:30:211 PDT [DEBUG] HtmlAnchor - Getting page for http://test.mycoolapp.com/login#, derived from href '#', using the originating URL http://test.mycoolapp.com/login
2011/05/24 17:59:30:211 PDT [DEBUG] HtmlElement - Firing Event beforeunload (Current Target: HTMLElement for HtmlHtml[<html xmlns="http://www.w3.org/1999/xhtml">]);
2011/05/24 17:59:30:215 PDT [DEBUG] JavaScriptJobManagerImpl - Waiting for all jobs to finish (will wait max 1000 millis).
2011/05/24 17:59:30:240 PDT [DEBUG] JavaScriptJobManagerImpl - Finished waiting for all jobs to finish (final job count is 0).
2011/05/24 17:59:30:241 PDT [DEBUG] JavaScriptJobManagerImpl - Waiting for all jobs that have execution time before 1000 to finish
2011/05/24 17:59:30:241 PDT [DEBUG] JavaScriptJobManagerImpl - Finished waiting for all jobs that have target execution time earlier than 1306285171241, final job count is 0
Possibly related to https://github.com/Nerian/akephalos2/issues/8