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.

Multiple Questions

jason.hamerjason.hamer Members
edited November -1 in Sahi - Open Source
Almost have automated my whole project... just got hung up in a couple of areas

1. some of our test verify by viewing the source..is this something I can use _containsHTML for?? if so could you give me code and example of verifying meta data??

2.I have another test where the staff is using firebug to verify a 301 redirect.. Is there anyway to verify a 301 redirect within SAHI?

3. Our application brings a pop up to upload images but SAHI does not recognize the windows dialog.

Thes are basically it. Any and all your help is GREATLY appreciated..

Comments

  • globalwormingglobalworming Moderators
    Hi jason

    1. I think you could use the .innerHTML option on the Elements you have to check
    element("yourElement").innerHTML.match("The text you want to check");

    2. I tried something like this:
    function getStatus($URL){
    
      var $httpRequest;
    
      var $status
      
      if (window.XMLHttpRequest) { // Mozilla, Safari, ...  
        $httpRequest = new XMLHttpRequest();
      } else if (window.ActiveXObject) { // IE  
        $httpRequest = new_ActiveXObject("Microsoft.XMLHTTP");  
      }  
    
    $httpRequest.open( "HEAD", $URL , false);
    $httpRequest.send(null);
    
    _alert($httpRequest.status);
    _alert($httpRequest.responseText); 
    }
    

    But though I got HTMLresponses, I couldn't capture Status 301, maybe someone else has an idea how to improve this

    regards Wormi
  • narayannarayan Administrators
    Hi Jason,

    1) _containsHTML can be used. Generally meta tags are one node above the body.

    _assert(_containsHTML(document.body.parentNode, "<meta name='' etc. ..."));

    You could also use something like
    _assertEqual("", document.getElementsByTagName("meta")[1].getAttribute("content"))
    to get the content attribute of a meta tag



    2) A 301 redirect will quickly change to the new URL. You can check the URL of the resultant page to make sure the 301 happened. To get the url use
    _assertEqual("expected url", location.href);


    3) Have a look at _setFile http://sahi.co.in/w/_setFile

    Regards,
    Narayan
Sign In or Register to comment.