User Tools

Site Tools


Sidebar



en:objects:browser:external_params:set_permissions

set_permissions

set_permissions($state="") - for specifying all JS navigator.permissions (including geolocation) (Available from version 7.0.44). For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API.

the input Function accepts parameters:

  • $state - can be 'granted', 'denied', or 'prompt' .

    After testing, the function returns the result of its work to the script:
  • true - successfully set
  • false - failed to set

    PHP example:

    <?php $xhe_host = "127.0.0.1:7023";
     
    //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> browser->".basename(__FILE__)."</font> <hr>";
     
    $app->clear();
    $browser->enable_proxy("", "socks://127.0.0.1: 9150");
     
    //1
    echo "1.Let's set the coordinates of New York:";
    echo $browser->set_geo("40.77659988", "- 73.95390320", "100")."<br>";
     
    //2
    echo "2.We grant all permissions as granted:";
    echo $browser->set_permissions("granted")." n";
     
    //3
    echo "3.Open google:";
    echo $browser->navigate("https://www.google.com/search?q=buy+car");
    sleep(1);
    $browser->set_vertical_scroll_pos(40000);
    $anchor->click_by_inner_text("Consider my location", 0);
    $anchor->click_by_inner_text("Update", 0);
     
    //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:7016"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> browser.xxxxxxxxx </font> <hr>")
     
    app.clear();
     
    # 1
    echo("1.Let's set the coordinates of New York:");
    echo(browser.set_geo("40.77659988", "- 73.95390320", "100"), "<br>");
     
    # 2
    echo("2.Give all permissions granted:");
    echo(browser.set_permissions("granted"), "
    ");
     
    # 3
    echo("3.Open google:");
    echo(browser.navigate("https://www.google.com/search?q=buy+car"));
    sleep(1);
    browser.set_vertical_scroll_pos(40000);
    anchor.click_by_inner_text("Follow my location", 0);
    anchor.click_by_inner_text("Update", 0);
     
     
    # 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:7016";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> browser.set_platform </font> <hr>");
     
    app.clear();
     
    //1
    echo("1.Let's set the coordinates of New York:");
    echo(browser.set_geo("40.77659988", "- 73.95390320", "100") + "<br>");
     
    //2
    echo("2.Give all permissions granted:");
    echo(browser.set_permissions("granted") + " n");
     
    //3
    echo("3.Open google:");
    echo(browser.navigate("https://www.google.com/search?q=buy+car"));
    sleep(1);
    browser.set_vertical_scroll_pos(40000);
    anchor.click_by_inner_text("Follow my location", 0);
    anchor.click_by_inner_text("Update", 0);
     
    //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:7016";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> browser.set_accept_language </font> <hr>");
     
    app.clear();
     
    //1
    echo("1.Let's set the coordinates of New York:");
    echo(browser.set_geo("40.77659988", "- 73.95390320", "100") + "<br>");
     
    //2
    echo("2.Give all permissions granted:");
    echo(browser.set_permissions("granted") + " n");
     
    //3
    echo("3.Open google:");
    echo(browser.navigate("https://www.google.com/search?q=buy+car"));
    app.sleep(1);
    browser.set_vertical_scroll_pos(40000);
    anchor.click_by_inner_text("Follow my location", 0);
    anchor.click_by_inner_text("Update", 0);
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/browser/external_params/set_permissions.txt · Last modified: 2026/08/05 22:32 (external edit)