User Tools

Site Tools


Sidebar

en:objects:browser:internal_params:enable_popup

enable_popup

enable_popup($enable=true,$refresh=true); - allow or prohibit loading and displaying pop-UPS (opening new pages) in the browser (when pop-UPS are disabled, the transition to the page is accelerated, but the start page may not be displayed correctly).
To check whether pop-UPS are allowed or prohibited in the browser, you can use this function is_enable_popup.
Note: when the option is disabled - clicks on links with target="_blank" will not be performed at all.

The function accepts parameters as input:

  • $enable – allow (true) or deny (false)
  • $refresh – whether to refresh (true) or not (false) the page after this command

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

    PHP example:

    <?php $xhe_host = "127.0.0.1:7010";
     
    //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>";
     
    //1
    echo "1.Let's open new windows:";
    echo $browser->enable_popup(true)."";
    echo $browser->is_enable_popup()." n";
     
    //2
    echo "2.Click on the 1st link of the Yandex issue - opening in the popup:";
    echo $browser->navigate("http://yandex.ua/yandsearch?text=%D1%82%D0%B5%D1%81%D1%82&lr=959&redircnt=1372064287.1&ncrnd=498")."";
    echo $anchor->get_by_attribute("class", "serp-item", false)->send_mouse_click()."<br>";
    sleep(2);
     
    //3
    echo "3.Disable opening new windows:";
    echo $browser->enable_popup(false)."";
    echo $browser->is_enable_popup()." n";
     
    //4
    echo "4.Let's try again to open 1 link of the yandex crescent in the popup:";
    echo $browser->navigate("http://yandex.ua/yandsearch?text=%D1%82%D0%B5%D1%81%D1%82&lr=959&redircnt=1372064287.1&ncrnd=498")."";
    echo $anchor->get_by_attribute("class", "serp-item", false)->send_mouse_click()."<br>";
     
    //close all popups
    $browser->close_all_tabs();
     
    //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:7010"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> browser.xxxxxxxxx </font> <hr>")
     
    # 1
    echo("1.Let's open new windows:")
    echo(browser.enable_popup(true), "")
    echo(browser.is_enable_popup(), "
    ")
     
    # 2
    echo("2.Click on the 1st link of the Yandex issue - opening in the popup:")
    echo(browser.navigate("http://yandex.ua/yandsearch?text=%D1%82%D0%B5%D1%81%D1%82&lr=959&redircnt=1372064287.1&ncrnd=498"), "")
    echo(anchor.get_by_attribute("class", "organic__url", false) .send_mouse_click(), "<br>")
    sleep(2)
     
    # 3
    echo("3.Disable opening new windows:")
    echo(browser.enable_popup(false), "")
    echo(browser.is_enable_popup(), "
    ")
     
    # 4
    echo("4.Let's try again to open 1 link of the yandex crescent in the popup:")
    echo(browser.navigate("http://yandex.ua/yandsearch?text=%D1%82%D0%B5%D1%81%D1%82&lr=959&redircnt=1372064287.1&ncrnd=498"), "")
    echo(anchor.get_by_attribute("class", "organic__url", false) .mouse_click(), "<br>")
     
    sleep(5);
    # close all popups
    browser.close_all_tabs()
     
    # 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:7010";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> browser.enable_popup </font> <hr>");
     
    //1 step
    echo("1.Let's open new windows:");
    echo(browser.enable_popup(true) + "<br>");
     
    //step 2
    echo("2.Let's open 1 link of the sickle in the popup:");
    echo(browser.navigate("http://yandex.ua/yandsearch?text=%D1%82%D0%B5%D1%81%D1%82&lr=959&redircnt=1372064287.1&ncrnd=498") + "");
    echo(anchor.get_by_attribute("class", "serp-item", false) .send_mouse_click(2,2) + "<br>");
    sleep(5);
     
    //step 3
    echo("3.Disable opening new windows:");
    echo(browser.enable_popup(false) + "<br>");
     
    //step 4
    echo("4.Open 1 link of the sickle in the popup:");
    echo(browser.navigate("http://yandex.ua/yandsearch?text=%D1%82%D0%B5%D1%81%D1%82&lr=959&redircnt=1372064287.1&ncrnd=498") + "");
    echo(anchor.click_by_attribute("class", "serp-item", false) + "<br>"); sleep(2);
    browser.close_all_tabs();
     
    //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:7010";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> browser.enable_popup </font> <hr>");
     
    //1 step
    echo("1.Let's open new windows:");
    echo(browser.enable_popup(true) + "");
    echo(browser.is_enable_popup() + " n");
     
    //step 2
    echo("2.Click on the 1st link of the Yandex issue - opening in the popup:");
    echo(browser.navigate("http://yandex.ua/yandsearch?text=%D1%82%D0%B5%D1%81%D1%82&lr=959&redircnt=1372064287.1&ncrnd=498") + "");
    echo(anchor.get_by_attribute("class", "serp-item", false) .send_mouse_click() + "<br>");
    browser.sleep(2);
     
    //step 3
    echo("3.Disable opening new windows:");
    echo(browser.enable_popup(false) + "");
    echo(browser.is_enable_popup() + " n");
     
    //step 4
    echo("4.Let's try again to open 1 link of the yandex crescent in the popup:");
    echo(browser.navigate("http://yandex.ua/yandsearch?text=%D1%82%D0%B5%D1%81%D1%82&lr=959&redircnt=1372064287.1&ncrnd=498") + "");
    echo(anchor.get_by_attribute("class", "serp-item", false) .send_mouse_click() + "<br>");
     
    //close all popups
    browser.close_all_tabs();
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/browser/internal_params/enable_popup.txt · Last modified: 2026/08/05 22:32 (external edit)