Execute test in responsive mode

We could also execute the test in responsive mode. Let us say for example iPhone 7

Steps to execute tests in Responsive mode - iPhone 7

  1. Create a new webfeed with name: responsive.webfeed.json Specify device name as iPhone 7 under experimentalOptions

responsive.webfeed.json

{
  "desiredCapabilities": {
  },
  "arguments": [
  ],
  "preferences": {
  },
  "extensions": [
  ],
  "experimentalOptions": {
    "mobileEmulation": {
      "deviceName" : "iPhone 7"
    }
  }
}
  1. Create a new config called responsive.properties and Specify target browser and webfeed. web.target & web.feed

responsive.properties

# Web Config

# Target Browser. Supported values <any | chrome | firefox | msedge>
web.target:chrome

# Feed file having desiredCapabilities, arguments etc
web.feed:responsive.webfeed
  1. Execute tests via gradle task

./gradlew clean runWebTests -Dconfig=responsive

Creating Gradle task to execute tests for responsive config

Another way to execute tests is to create a Gradle task-specific to firefox config as below:

task runWebTestsOnResponsive(type: Test) {
    systemProperties = [
            config         :  "responsive"
    ]
    filter {
        excludeTestsMatching "*.mobile.*"
        excludeTestsMatching "*.api.*"
        excludeTestsMatching "*.db.*"
    }
    outputs.upToDateWhen { false }
    useTestNG {
        parallel = "methods"
        threadCount Integer.parseInt(System.getProperty("sessions", "2"))
        includeGroups System.getProperty("tags", "web")
        testLogging.showStandardStreams = true
        useDefaultListeners true
        outputDirectory = file("$buildDir/" + System.getProperty('tags', 'NONE'))
    }
}

Call the task like below:

./gradlew clean runWebTestsOnResponsive

Failing test

Please note: The test fails due to change in locators / change in behavior of application due to responsive nature. In the next article, let us see how to address this problem