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.

check popup doesn't exists ?

shackshack Members
edited November -1 in Sahi - Open Source
I want to check that the popup doesn't opens after a linkclick.

I tried this

if(_exists(_popup("404 Not Found")))

if(_isvisible(_popup("404 Not Found")))

without success

Comments

  • Hi shack,

    You can use:

    _assertNotExists(_popup("404 Not Found"));

    Regards
    Sumitra
  • Hi Sumitra,

    this doesn't work for me.

    I get this error message
    Jan 23, 2012 8:13:10 AM net.sf.sahi.command.CommandExecuter execute
    WARNING: java.lang.reflect.InvocationTargetException
            at sun.reflect.GeneratedMethodAccessor200.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at net.sf.sahi.command.CommandExecuter.execute(CommandExecuter.java:55)
            at net.sf.sahi.LocalRequestProcessor.handleDyn(LocalRequestProcessor.jav
    a:67)
            at net.sf.sahi.LocalRequestProcessor.getLocalResponse(LocalRequestProces
    sor.java:40)
            at net.sf.sahi.ProxyProcessor.processLocally(ProxyProcessor.java:209)
            at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:86)
            at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range:
     -36
            at java.lang.String.substring(Unknown Source)
            at net.sf.sahi.rhino.ScriptRunner.getFromStep(ScriptRunner.java:253)
            at net.sf.sahi.rhino.ScriptRunner.getPopupNameFromStep(ScriptRunner.java
    :238)
            at net.sf.sahi.rhino.ScriptRunner.getStepJSON(ScriptRunner.java:299)
            at net.sf.sahi.command.Player.getCurrentStep(Player.java:135)
            ... 9 more
    
    Rhino lib:Step >_sahi._assertNotExists(_sahi._popup("404 Not Found"));< did not
    complete in 150 seconds.
    
  • Hi shack,

    Could you please have a look at: http://sahi.co.in/forums/viewtopic.php?id=3307

    Check if this solves your issue.

    Regards
    Sumitra
  • Hi Sumitra,

    no success with a longer script.max_cycles_for_page_load value.

    It throws still the exception.

    I just want to check if there is no popup with the title 404 Not Found.

    Is there no easy way to check this ?
  • Hi Shack,

    Could you try the following code:
    _navigateTo("http://sahi.co.in/demo");
    _click(_link("Window Open Test"));
    _popup("popWin").close();
    var $exists= _popup("popWin").exists();
    if(!$exists){
     _alert("popup didnt open");
    } else {
     _alert("popup opened");
    }
    

    Regards
    Sumitra
  • still no success
  • Hi Shack,

    I hope this should work where in you can check if an element is present on the popup.
    _navigateTo("http://sahi.co.in/demo/");
    _click(_link("Window Open Test"));
    var $exists = _link("Formd Test").exists();
    if(!$exists==false){
    _alert("popup does not open");
    } else {
    _alert("popup exists");
    }
    

    Regards
    Sumitra
  • .exists() is not a function for me... Maybe its a new function in latest build?
  • CathySoQACathySoQA Members
    edited January 2013
    I know this is an old thread, but I can't get this code to work. I am trying to create a function to click buttons in our app that can be images or actual buttons. The code above currently is not working in Sahi Pro 4.3.2, it always returns false. I have tried _imageSubmitButton("ctl00\$btnDelete\$btn").exists() and _exists(_imageSubmitButton("ctl00\$btnDelete\$btn")) and neither one will work but the button is in fact on the page, I can record clicking it and it will play back. Any ideas?
Sign In or Register to comment.