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.

Problem with link

cragucragu Members
edited November -1 in Sahi - Open Source
Hi,

In one of my web page i have a link in a icon(in other words we are treating the icon as link) but it doesn't have any href(href = #) and while clicking the link it calls a functions and opens a window. When playback the script sahi clicks the link and the window opened but sahi keep on trying to click the link and the test gets failed.

Please guide me to solve this.

regards
Ragu
Tagged:

Comments

  • Hi,

    To give you more info on this, in log for the step, "TypeError: null is null or not an object" message is displaying.

    Any suggestions????

    Thanks
    Ragu
  • If you know the function the you can directly call that function instead of clicking the link.
    Use _call(); to call the function.
    Ex. if onclick = FunctionAfterIconClick() is used in browser code than _call(FunctionAfterIconClick()); will work.
  • Thanks for the reply. I tried with that too. Its not working for me. Actually html for the link is
    onclick="return FnAfterLinkClick('value')
    

    I tried using
    
    _call(fnAfterLinkClick());
    
    _call(FnAfterLinkClick('Value'));
    
    _call(FnAfterLinkClick(),"Value");
    

    and in the log i am getting TypeError: Object Expected

    Actually clicking the link is working fine and it is opening the dialog box but sahi repeats the step of clicking the link and fails the test and giving the error message "null is null or not an object".

    Thanks
    Ragu
  • Hi All,

    It would be a great helpful, if you could share your idea on the above problem.

    Narayan,

    Do you have any thoughts on the cause of the above problem. "null is null or not an object".

    Regards
    ragu
  • narayannarayan Administrators
    Having a look at this. What browser are you using?
  • I am using IE 7, if i use Firefox i am getting "document.getElementById("btnSearchPreset") is null" in the sahi controller.
  • Did you try _eval?
    This will diff combination with eval as you have used in call. Ex. _eval("return FnAfterLinkClick('value')");
  • narayannarayan Administrators
    Guys,

    What you are trying to do are all workarounds. In these cases you are testing the function working correctly, but not that it was called correctly when the click happened. Sahi should be able to click the element using _click and things should work correctly. This is really a bug.

    cragu,
    Could you do this and check if the link works for you?

    1) Open sahi/htdocs/spr/concat.js in a text editor.
    2) Search for Sahi.prototype.linkClick
    3) Replace that function with this:
    Sahi.prototype.linkClick = function (e) {
        if (!e) e = window.event;
        var performDefault = true;
        var el = this.getTarget(e);
        this.lastLink = this.getEncapsulatingLink(el);
        if (this.lastLink.prevClick) {
            try{
                performDefault = this.lastLink.prevClick.apply(this.lastLink, arguments);
            }catch(ex){}
        }
        this.lastLinkEvent = e;
        if (performDefault != false) {
            window.setTimeout(function(){_sahi.navigateLink()}, 10);
        } else {
            return false;
        }
    };
    

    4) Restart Sahi, clear browser cache and try it again.

    Let me know what you see.

    Regards,
    Narayan
  • Narayan,

    Thanks a lot... Just to confirm before proceed, as i am using Oct 26 2008 build, in the concat.js file, i am seeing the following 2 functions. i don't see Sahi.prototype.linkClick
    var linkClick = function (e) {
        var performDefault = true;
        if (this.prevClick) {
            performDefault = this.prevClick.apply(this, arguments);
        }
        if (performDefault != false) {
            _sahi.navigateLink(this);
        }
    
    and
    
    Sahi.prototype.navigateLink = function (ln) {
        if (!ln) return;
        var win = this.getWindow(ln);
        if (ln.href.indexOf("javascript:") == 0) {
            var s = ln.href.substring(11);
            win.setTimeout(unescape(s), 0);
        } else {
            var target = ln.target;
            if (ln.target == null || ln.target == "") target = "_self";
            if (this.isSafariLike()) {
                var targetWin = win.open("", target);
                try {
                    targetWin._sahi.onBeforeUnLoad();
                } catch(e) {
                    this._debug(e.message);
                }
                targetWin.location.href = ln.href;
            }
            else win.open(ln.href, target);
        }
    }
    
    

    I need to replace the var linkclick() function with your new function right? Just to remind you, in my case sahi clicks the link and the window is getting opened but sahi keep on trying to click the link.

    So sahll i proceed with replacing the function? waiting for your comment.

    Thanks
    Ragu
  • narayannarayan Administrators
    If this is an old build, try replacing

    if (this.prevClick) {
    performDefault = this.prevClick.apply(this, arguments);
    }

    with

    if (this.prevClick) {
    try {
    performDefault = this.prevClick.apply(this, arguments);
    }catch(e){}
    }
  • After replacing as you mentioned also there is no difference. Sahi executing the particular step _Click(_link("uc512_name")); and opening the target window. Then again sahi executing the same step 5 times and the test fails. In the log it shows
    _Click(_link("uc512_name")); TypeError: 'null' is null or not an object.

    and in the sahi.bat

    it showing Rhino lib:### Step did not return in 5 minuties.

    Waiting for your comments.

    Thanks
    Ragu
  • Narayan,

    Do you think this is a bug in sahi? because sahi clicks other links in this application and its working correctly. But in the case of the particular link, actually it is an image which is defined as link and its href=# but when clicking the link its opening the web page dialog window(which has the URL in it).

    Sahi clicks the image link and opens the window correctly but why still sahi trying to click the link. What sahi is expecting in this case?

    Awaiting your comments?

    Thanks
    Ragu
  • Narayan,

    In the application for the link, Ajax tool control and updatepanel are used. is it the cause of the problem?

    Thanks
    Ragu
Sign In or Register to comment.