wait_element_exist_by_xpath

wait_element_exist_by_xpath($xpath); - this function is used to wait for a page element to appear, checking it against the specified xpath.

Available from version 7.0.45

the input Function accepts parameters:

  • $xpath – xpath of the specified element (string).

    The element timeout is set using the variable $iSecondsWaitElementExistBeforeAction=15; //how many seconds to wait for the element defined in the xweb_human_emulator template file to appear for each language.



    PHP example: anchor->".basename(__FILE__)."
    "; //1 echo "1.Let's go to the polygon:"; echo $browser->navigate("http://humanemulator.net/poligon/anchor.html")."
    "; //2 echo "2.waiting for an element given by xpath:
    "; $anchor->wait_element_exist_by_xpath("/html [1]/body [1]/a [2]"); //3 echo "3.Get the x and y of the element with the given xpath:"; $obj = $anchor->get_by_xpath("/html [1]/body [1]/a [2]"); echo $obj->get_x()."".$obj->get_y(); //end echo "

    "; //Quit $app->quit(); ?>
    Python example: # Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7011" from xweb_human_emulator import * # Start echo("
    common.wait_element_exist_by_xpath
    ") # 1 echo("1.Let's go to the polygon:") echo(browser.navigate("http://www.humanemulator.net/poligon/image.html"), "
    ") # 2 echo("2.Let's wait for the picture with the given xpath and click on it:") image.wait_element_exist_by_xpath("/html/body/p/img") # 3 echo("3.Get x and y from the image with the given xpath and click on it:") obj = image.get_by_xpath("/html/body/p/img") echo(obj.get_x(), "") echo(obj.get_y(), "") echo(obj.click(), "
    ") # end echo("

    ") # 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:7011"; InitXHE(); //Start echo("
    wait_element_exist_by_xpath
    "); //1 step echo("1.Let's go to the polygon:"); echo(browser.navigate("www.humanemulator.net/poligon/image.html") + "
    "); //step 2 echo("2.Wait for element by xpath:"); image.wait_element_exist_by_xpath("/html [1]/body [1]/img [1]"); //step 3 echo("3.Get x and y by xpath:"); XHEInterface obj = image.get_by_xpath("/html [1]/body [1]/img [1]"); echo(obj.get_x() + "" + obj.get_y()); //end echo("

    "); app.quit(); } }
    Java Script example: //connect the object to control the emulator, if not already connected xhe_host = "127.0.0.1:7031"; echo = require("../../../Templates JS/xweb_human_emulator.js"); //Start echo("
    anchor.wait_element_exist_by_xpath
    "); //1 step echo("1.Let's go to the polygon:"); echo(browser.navigate("http://www.humanemulator.net/poligon/image.html") + "
    "); //step 2 echo("2.Wait for element with given xpath:"); image.wait_element_exist_by_xpath("//html [1]/body [1]/img [1]"); //step 2 echo("2.Get the x and y of the element with the given xpath:"); obj = image.get_by_xpath("//html [1]/body [1]/img [1]"); echo(obj.get_x() + "" + obj.get_y() + ""); echo(obj.click() + "
    "); //end echo("

    "); //Quit app.quit();