18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

MouseOverTexte

escapeescape Members
edited November -1 in Sahi - Open Source
Hi Everybody

I know that there is the possiblity to simulate a mouse over event in sahi, during replay I can see the mouse hovering over the given element and a mouseovertext is shown - my question is how to verify these text :-). Is there any possibility?

Thanks for help

Best regards

Comments

  • narayannarayan Administrators
    If it is an image, then you could see if _image("id").alt or _image("id").title is the one you want.
    If the mouseover text is via javascript, you will have to find out what div or span is being displayed and then assert its contents.
  • Hi

    first it is an image, I can simulate a mouseover event: _mouseOver(_image(51)) - but I can't verify the text (that is correctly shown in the Browserwindow).
    The text comes via javascript, I can call the function:

    _image(51).onmouseover or _call(__image(51).onmouseover)

    I get the result ((via the sahi [test-->] button )):

    function anonymous()
    {
    /*********some mousover text ; D ********//
    }


    How can I verify this text ?!?!?the text itself don't seems to be a element so I think _div(???) and _span (????) don't work....
  • narayannarayan Administrators
    Try this:
    _mouseOver(_image(51));
    _assertNotNull(_spandiv('text_on_mouseover'));
    
    _spandiv will kind of look for any span or div with the given text. Use a regular expression if that does not work. eg. _spandiv(/text_on_.*/).

    It may happen that the span/div was always on the page but not visible. In that case, _assertNotNull(_spandiv('text_on_mouseover')) will return true even before the mouse over. In that case, use
    _assertEqual('block', _style(_spandiv('text_on_mouseover'), 'display'))
    
    or
    _assertEqual('inline', _style(_spandiv('text_on_mouseover'), 'display'))
    
    depending on which works.

    What we are checking for is similar to _spandiv('text_on_mouseover').style.display == 'block' or 'inline'




    If it is possible, send a snippet of the html code.
  • Hey

    first thanks for this input - the frist snipet of code doesn't work in my case

    now I have tested the following:

    _assertEqual(/.*my_mouse_over_text'.*/,_image(51).outerHTML);

    but the assertion fails , it looks like as if the reg expr is not handled correct.
  • narayannarayan Administrators
    _assertEqual does not take a regex as an argument.
    On the controller, evaluate _image(51).alt or _image(51).title and see what you get.
    If you do not get the desired text, post some html here.
    outerHTML is not supported on all browsers.
  • Hi,

    I also need to use regular expressions in assertions. Any help will be great :)

    Regards,
    Pankaj.
  • Hi,

    Please comment on the code below and let me know where i am wrong...

    var $aA = top.document.getElementsByTagName('span')[132];
    var $aAVal = parseInt($aA.getAttribute("innerText"));
    var $text = "xyz" + $aAVal + "abc";
    _assertContainsTextNew($text, _byId("id_xyz"));

    when i run this code through the script it gives error: undefined object.
    but if i run the same in the sahi controller (Evaluate Expression) it works fine.

    What I need to do is as follows:
    A particular number(string value) appears as a link on the page and I first need to convert the number to integer value and pass it to a variable which i want to use in an assertion.
    Any workarounds will be a great help.

    Regards,
    Pankaj.
  • narayannarayan Administrators
    top.document.getElementsByTagName is a page dependent variable.

    Do this:
    function getMyText(){
      var $aA = top.document.getElementsByTagName('span')[132];
      var $aAVal = parseInt($aA.getAttribute("innerText"));
      var $text = "xyz" + $aAVal + "abc";
      return $text;
    }
    _assertContainsTextNew(getMyText(), _byId("id_xyz"));
    
    Please read up on these links, to understand how to write scripts in Sahi:
    http://sahi.co.in/w/sahi-script-and-javascript
    http://sahi.co.in/w/Script/

    Btw, what is _assertContainsTextNew? Is it a scheduler function you have added?
  • Thanks a lot Sir. Thats working. however i still face the problem when i try to assign the value returned by the function to a variable.
    The _assertContainsTextNew() is similar to assertContainsText(). Was trying to return the desired value.

    Regards,
    Pankaj.
Sign In or Register to comment.