User Tools

Site Tools


Sidebar

en:objects:webpage:work_html:set_body

set_body

set_body($body); - set a new page content (for better performance ,it is advisable to use it immediately after navigation)

the input Function accepts parameters:

  • $body – new body (body tag) of the page

    After testing, the function returns the result of its work to the script :
  • true – operation completed successfully
  • false – operation failed to complete successfully

    PHP example:

    <?php $xhe_host = "127.0.0.1:7013";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
      $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> webpage->".basename(__FILE__)."</font> <hr>";
     
    //1
    echo "1.Let's go to the polygon:";
    echo $browser->navigate("http://www.humanemulator.net/poligon/anchor.html")."<br>";
     
    //2
    echo "2.Replace the script message:";
    $body = $webpage->get_body();
    $body = str_replace("mouse down", "mouse down changed body", $body);
    $body = str_replace("mousedown", "mouse down changed body", $body);
    $body = str_replace("3", "1", $body);
    echo $webpage->set_body("New")."";
    sleep(2);
    echo $webpage->set_body($body)."<br>";
     
     
    //3
    echo "3.Send an event to the changed element:";
    echo $anchor->send_event_by_name("onmousedown", "onmousedown")."<br>";
     
    //4
    echo "4.Get the text of the last message(even if it was hidden):";
    echo $browser->get_last_messagebox_text();
     
    //end
    echo "<hr> <br>";
     
    //Quit
    $app->quit();
    ?>

    Python example:

    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
     
    xhe_host = "127.0.0.1:7029"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> webpage.xxxxxxxxx </font> <hr>")
     
    # 1
    echo("1.Let's go to the polygon:")
    echo(browser.navigate("http://www.humanemulator.net/poligon/anchor.html"), "<br>")
     
    # 2
    echo("2.Replace the script message:")
    body = webpage.get_body();
    body = body.replace("onmouseover", "onmouseovernew");
    echo(webpage.set_body(body), "<br>")
     
     
    # end
    echo("<hr> <br>")
     
    # Quit
    app.quit()

    C# example:

    #region using
     
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
     
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
     
    #endregion
     
     class Program: XHEScript
     {
    static void Main(string [] args)
    {
    //init XHE
    server = "127.0.0.1:7031";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> webpage.set_body </font> <hr>");
     
    //1 step
    echo("1.Let's go to the polygon:");
    echo(browser.navigate("http://www.humanemulator.net/poligon/anchor.html") + "<br>");
     
    //step 2
    echo("2.Replace the script message:");
    string body = webpage.get_body();
    body = body.Replace("mousedown", "mouse down changed body");
    echo(webpage.set_body(body) + "<br>");
     
    //step 3
    echo("3.Send an event to the changed element:");
    echo(anchor.send_event_by_name("onmousedown", "onmousedown") + "<br>");
     
    //step 4
    echo("4.Get the text of the last message(even if it was hidden):");
    echo(browser.get_last_messagebox_text());
     
    //end
    echo("<hr> <br>");
     
    app.quit();
    }
    }

    Java Script example:

    //connect the object to control the emulator, if not already connected
    xhe_host = "127.0.0.1:7029";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> webpage.set_body </font> <hr>");
     
    //1 step
    echo("1.Let's go to the polygon:");
    echo(browser.navigate("http://www.humanemulator.net/poligon/anchor.html") + "<br>");
     
    //step 2
    echo("2.Replace the script message:");
    bdy = webpage.get_body();
    bdy = bdy.replace("mousedown", "mouse down changed body");
    bdy = bdy.replace("3", "1");
    echo(webpage.set_body("New") + "");
    browser.sleep(2);
    echo(webpage.set_body(bdy) + "<br>");
     
    //step 3
    echo("3.Send an event to the changed element:");
    echo(anchor.send_event_by_name("onmousedown", "onmousedown") + "<br>");
     
    //step 4
    echo("4.Get the text of the last message(even if it was hidden):");
    echo(browser.get_last_messagebox_text());
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/webpage/work_html/set_body.txt · Last modified: 2020/10/13 18:47 (external edit)