0

I am working on Test Automation Script using JAVA and Selenium WebDriver , My test is running on cloud environment (crossbrowsertesting.com). There is an feature to take snapshots of browser window , When I was using RemoteWebDriver this line of code work fine , but need to replace it with WebDriver because reason not bale to get windowHandles. But I am getting following error now , stating "The method getSessionId() is undefined for the type WebDriver"

snapshotHash=myTest.takeSnapshot(driver.getSessionId().toString());

//takeSnapshot method :

public String takeSnapshot(String seleniumTestId) throws UnirestException {
        System.out.println("Screen Shots Taken.");

        /*
         * Takes a snapshot of the screen for the specified test.
         * The output of this function can be used as a parameter for setDescription()
         */
        HttpResponse<JsonNode> response = Unirest.post("http://crossbrowsertesting.com/api/v3/selenium/{seleniumTestId}/snapshots")
                .basicAuth(username, api_key)
                .routeParam("seleniumTestId", seleniumTestId)
                .asJson(); 
        // grab out the snapshot "hash" from the response
         snapshotHash = (String) response.getBody().getObject().get("hash");

        return snapshotHash;
    }
cod
  • 151
  • 4
  • 13

1 Answers1

0

I dont quite understand why you need to use "WebDriver" in place of "RemoteWebDriver" ? "RemoteWebDriver" is the mother of all web driver implementations and it should be good enough to work with any remote grid environment. I dont understand why you need to switch to using "WebDriver" reference which is one of the interfaces that "RemoteWebDriver" implements. getSessionId() is NOT part of any interface specifications but its a direct implementation that RemoteWebDriver provides.

getWindowHandles() is part of WebDriver interface specification and you should still be able to use it.

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66