Partage
  • Partager sur Facebook
  • Partager sur Twitter

JQuery test with wicket

    3 novembre 2014 à 15:39:25

    I have an ajaxEditableLabelWithIcon which is a ajaxEditableLabel with a modified HTML that contain an icon. When the user click this icon, the editor field become editable and when he click again, the content is saved. We did that using JQuery :
       
     function editOrSubmit(element){
     
        panel = element.parentElement;
       label = panel.children[0];
       if(panel.find){
       e = $.Event('keypress');
          e.which = 13; // Enter key
          label.trigger(e); //submit the FormTester
       }
       else{
       label.click(); //Wich make the label editable
       }
        }
    Now, I want to test it using JUnit. Since I can't directly click on the icon, I tried to create a javascript shortcut to the function, and then create a Robot to trigger the KeyPressed events :
       
     // defining flags
    var isCtrl = false;
    var isShift = false;
     
    $(document).ready(function() {
    // action on key up
    $(document).keyup(function(e) {
    if(e.which == 17) {
    isCtrl = false;
    }
    if(e.which == 16) {
    isShift = false;
    }
    });
    // action on key down
    $(document).keydown(function(e) {
    if(e.which == 17) {
    isCtrl = true; 
    }
    if(e.which == 16) {
    isShift = true; 
    }
    // En cas d'appui sur ctrl+Shift+F9 en même temps, la méthode editOrSubmit est appelée
    if(e.which == 120 && isCtrl && isShift) { 
    var icon = document.getElementById("icon");
    editOrSubmit(icon);
    } 
    });
     
    });
    It work well in a browser, but inside the test nothing happen ? Do you know why ?

    -
    Edité par Maxime00 3 novembre 2014 à 15:40:18

    • Partager sur Facebook
    • Partager sur Twitter
      3 novembre 2014 à 16:06:22

      Hi,

      I'll move your topic in a more appropriate forum (English section)

      Max 

      -
      Edité par max-om-93 3 novembre 2014 à 16:47:04

      • Partager sur Facebook
      • Partager sur Twitter

      JQuery test with wicket

      × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
      × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
      • Editeur
      • Markdown