Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Jul 18, 2018 12:16

Introduction

When using automation (either Perfecto Native Automation or Selenium/Appium) to browse to a URL in the device's browser, you have a choice of using the Browser go to Perfecto command from Native Automation or the get() method of the RemoteWebDriver instance in Selenium/Appium. Both of these methods, send the URL to the device browser and display the page specified. However, when executing the command as part of an automation script the control returns to the subsequent script command even before the page is displayed in the browser and no validation is performed. The green success status confirmation within the execution report does not validate that the browser was opened; rather it validates that the native command request was successfully received by the device OS.

Note: This feature is currently supported for Android devices only.

Synchronize Your Browsing

To browse to the website and wait for the page to actually load before advancing to the next automation step - use the WaitForPageLoad option. This option causes the browsing automation operation to wait until the page is displayed before returning control to the automation script. In this way, you can plan your next automation steps to perform actions on the displayed page.

WaitForPageLoad in Native Automation

In Perfecto Native Automation, use the Browser go to command to specify the URL of the website to browse to. You can set the WaitForPageLoad parameter to true for the browser action.

When executing the automation script, the completion of the step will be delayed until the page is displayed in the device browser.

WaitForPageLoad in Selenium

To browse to a given URL in a Selenium automation script, we advise using the get() method of the RemoteWebDriver. This method supports a URL as its parameter and browses to the website.

To force the method to work synchronously, meaning that it will return control to the automation script only after the website has completed displaying the target URL (or if there is a failure), set the Capability, WaitForPageLoad, to true.

Note: Setting the capability to true will affect all browsing activation in the automation script.

The following snippet shows both setting the capability value and activating the browser operation.

        DesiredCapabilities capabilities = new DesiredCapabilities(browserName, "", Platform.ANY);
        String host = MY-LAB;
        capabilities.setCapability("user", MY-USER);
        capabilities.setCapability("password", MY-PW);
    // Add capabilities to select the device or activate other features
        PerfectoLabUtils.setExecutionIdCapability(capabilities, host);
    // Use capability to make all browsing synchronous
        capabilities.setCapability("perfecto:waitForPageLoad", true);
   
        RemoteWebDriver driver = new RemoteWebDriver(new URL("http://" + host + "/nexperience/perfectomobile/wd/hub"), capabilities);

        driver.manage().timeouts().implicitlyWait(106, TimeUnit.SECONDS);

        try {
    // Browse to the website, returning only after page is displayed
            driver.get("cnn.com");
        } catch (Exception e) {
            e.printStackTrace();
        }