Search code examples
seleniumjenkinsselenium-webdriverselenium-grid

Selenium Grid2 Print Screen


I was wondering how people have gone about getting screenshots from a selenium grid test. Presumably my screenshot will be saved to the machine the selenium node is running on, how can I then get it back to a common location? Ideally I want my images to all be in the work directory in Jenkins...


Solution

  • The screenshot is saved to the machine the machine you're executing the tests on, not the grid nodes. We are not using Jenkins, but using a Ruby environment.

    #Ruby Screenshot
    driver = Selenium::WebDriver.for :ie
    driver.get "https://www.google.com"
    driver.save_screenshot("./screen.png")
    

    The screenshot is stored on the machine where you instantiate the webdriver from that instance of the webdriver connects to the selenium grid. I believe there is an environment variable in Jenkins that allows you to set where they are stored. I have a limited knowledge of Jenkins though.