Set viewport in profile?

Hi all, is there a way to specify a viewport of a particular profile? For example, if I wanted a mobile profile, could I set it to always use a viewport of 375x812 to simulate it?

I’m trying to adapt some of my test cases to account for differences on mobile but running the Android emulator is proving too much for my computer so I’m hoping to find a workaround. It seems like this would be possible but I’m not sure what I’m missing.

I don’t want to add a test step to change the viewport because I want the same test to be able to run on desktop or mobile, so if I can use a profile to specify the viewport, that would be a good solution, I think.

This is what I’ve tried:


As a workaround, I’ve created a profile called ‘Mobile’ and am putting this into the beginning of each test case:

def executionProfile = RC.getExecutionProfile()

if (executionProfile == 'Mobile') {
	WebUI.setViewPortSize(300, 800)

But I’m hoping there’s a more elegant solution!

I don’t think there is a way to do this as straightforward as you’d like. But you could add a listener that picks up the profile setting and assigns it via WebUI.setViewPortSize(). As a refinement, you could use -1 to indicate “maximize”.

GlobalVariable Value
viewportX 375
viewportY 812

class Listener_VPSize {
   * Executes before every test case.
   * @param testCaseContext related information of the executed test case.
  def beforeTestCase(TestCaseContext testCaseContext) {
    if(GlobalVariable.viewportX == -1) {
    } else {
      WebUI.setViewPortSize(GlobalVariable.viewportX, GlobalVariable.viewportY)


I haven’t tested this, but it looks okay from here.

Thanks! I haven’t experimented with listeners yet so I can check this out.