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.

get iframe using specific attribute

edited November -1 in Sahi - Open Source
I want to use the below method.
API
_iframe(identifier)
HTML <iframe src="" name="name" id="id" ></iframe>
Identifier
name, id, index
Example _iframe("id");

But instead of name or id or index I want to use the combination of class and title attribute for getting the iframe since my code is as below.
<iframe class="rte" width="100%" height="95" frameborder="0" style="position: relative;" src="" sc_dojotype="scayt.ui" title="txtFeatureMarketingText">

How to do this ?
What should be changed in the concat.js or is there any other way to do it?

thanks and regards,
rahoolm

Comments

  • Got the solution:
    In one line to get attribute "title"
    _getAttribute(_byClassName("rte", "iframe", _div("rightSlideIn")), "title")

    or
    you can use
    var $obj = _byClassName("rte", "iframe", _div("rightSlideIn"))

    _getAttribute($obj, "title")
    txtFeatureMarketingText

    _getAttribute($obj, "src")

    My next target is to get the contents of element and then modify it.

    Here is the complete code.
    <iframe style="position: relative;" class="rte" title="txtFeatureMarketingText" height="80" src="" frameBorder="0" width="100%" sc_dojoType="scayt.ui">
        <!DOCTYPE html>
        <html>
        <head><meta content="text/html; charset=unicode" http-equiv="Content-Type"><link rel="stylesheet" type="text/css" href="../common/styles/emxUIDefault.css"><link rel="stylesheet" type="text/css" href="function _Array_find(varItem) {        var blnFound = false;        for (var i=0; i  < this.length &amp;&amp; !blnFound; i++) {                if (this[i] == varItem) {                        blnFound = true;                }        }        return (blnFound ? i-1 : -1);}"><link rel="stylesheet" type="text/css" href="function _Array_remove(varItem) {        var intPos = this.find(varItem);        if (intPos > -1) {                for (var i= intPos + 1; i < this.length; i++) {                        this[i-1] = this[i];                }                this.length--;        }}"><link rel="stylesheet" type="text/css" href="function(func, data) {&#9;var res = [];&#9;for (var i = 0; i < this.length; i++) {&#9;&#9;res.push(func(this[i], i, this, data));&#9;}&#9;return res;}"><meta name="GENERATOR" content="MSHTML 9.00.8112.16455">
        </head>
        <body style="padding: 5px; background-color: white;">
        </body>
    </iframe>
    
    I am not interested in the complete content modification but only the
    <body ...> 
    </body> 
    
    part.
    Under this body one can add html tags like
    <p>
    <b></b>
    <i> </i>
    

    Can anybody please help me?

    regards,
    rahoolm
  • Got the complete solution at last. People can use if they want.
    
    var $str ="<p><b>Welcome To Sahi Web Automation</b> <p>It is working fine. <p><i>I can even write in Italics</i>"
    var $obj = _byClassName("rte", "iframe", _div("rightSlideIn"));
    _rteWrite($obj, $str);
    

    regards,
    rahoolm
Sign In or Register to comment.