Can I run app from script, interact with the simulator and take screenshots from the script?

I'd like to do some fine-tuning of the layouts, and my idea is to write some script that in loop starts the data field in the simulator for each device then it follows a script, like:

for device in devices:
  click_button(up)
  for layout in device's layouts
    change_layout(layout)
    screenshot("screen1-$device-$layout.png")
  click_button(menu)
  for layout in device's layouts
    change_layout(layout)
    screenshot("screen2-$device-$layout.png")

Then I can look at the images and spot obvious layout problems that needs to be fixed.

  • An idea to spot the obvious problems.

    I am using a global variable testMode. When it is true , I will do a switchProperties operation, in which all the possible values for each property will be traversed. Just spot the issues in this process. A little hard for eyes to concentrate quite a long time

        if (testMode) {
          // switchProperties();
        }
    
      // (:debug)
      // function switchProperties() as Void {
      //   gridDataIndex = gridDataIndex + 1;
      //   var themes = [30, 31, 32, 33, 34, 35, 37];
      //   Properties.setValue("theme_code", (gridDataIndex - 1) % themes.size());
    
      //   if (gridDataIndex < 5) {
      //     Properties.setValue("j", 0);
      //     Properties.setValue("zb", 1);
    
      //     var bottomUpDataTypeList = [1, 2, 3, 4, 5, 6];
    
      //     Properties.setValue("zi", true);
      //     Properties.setValue("h", true);
      //     Properties.setValue(
      //       "i",
      //       bottomUpDataTypeList[gridDataIndex % bottomUpDataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "zj",
      //       bottomUpDataTypeList[(gridDataIndex + 1) % bottomUpDataTypeList.size()]
      //     );
    
      //     var grid1DataTypeList = [1, 2, 3, 4, 7, 8, 9, 10, 11];
      //     var grid2DataTypeList = [1, 2, 3, 4, 7, 8, 9];
      //     var grid3DataTypeList = [1, 2, 3, 4, 7, 8, 9];
      //     var grid4DataTypeList = [1, 2, 3, 4, 7, 8, 9];
      //     var grid5DataTypeList = [1, 2, 3, 4, 7, 8, 9];
      //     var grid6DataTypeList = [1, 2, 3, 4, 7, 8, 9];
    
      //     Properties.setValue(
      //       "zc",
      //       grid1DataTypeList[gridDataIndex % grid1DataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "ze",
      //       grid2DataTypeList[(gridDataIndex + 1) % grid2DataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "zg",
      //       grid3DataTypeList[(gridDataIndex + 2) % grid3DataTypeList.size()]
      //     );
    
      //     Properties.setValue(
      //       "k",
      //       grid4DataTypeList[(gridDataIndex + 3) % grid4DataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "m",
      //       grid5DataTypeList[(gridDataIndex + 4) % grid5DataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "o",
      //       grid6DataTypeList[(gridDataIndex + 5) % grid6DataTypeList.size()]
      //     );
      //   } else if (gridDataIndex < 10) {
      //     var bottomUpDataTypeList = [1, 2, 3, 4, 5, 6];
    
      //     Properties.setValue("j", 1);
      //     Properties.setValue("zb", 1);
      //     Properties.setValue("zi", true);
      //     Properties.setValue("h", true);
      //     Properties.setValue(
      //       "i",
      //       bottomUpDataTypeList[gridDataIndex % bottomUpDataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "zj",
      //       bottomUpDataTypeList[(gridDataIndex + 1) % bottomUpDataTypeList.size()]
      //     );
    
      //     var grid1DataTypeList = [1, 2, 3, 4, 7, 8, 9];
      //     var grid2DataTypeList = [1, 2, 3, 4, 7, 8, 9];
      //     var grid3DataTypeList = [1, 2, 3, 4, 5, 7, 8, 9];
      //     var grid4DataTypeList = [1, 2, 3, 4, 5, 7, 8, 9];
      //     var grid5DataTypeList = [1, 2, 3, 4, 7, 8, 9];
      //     var grid6DataTypeList = [1, 2, 3, 4, 5, 7, 8, 9];
    
      //     Properties.setValue(
      //       "zc",
      //       grid1DataTypeList[gridDataIndex % grid1DataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "ze",
      //       grid2DataTypeList[(gridDataIndex + 1) % grid2DataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "zg",
      //       grid3DataTypeList[(gridDataIndex + 2) % grid3DataTypeList.size()]
      //     );
    
      //     Properties.setValue(
      //       "k",
      //       grid4DataTypeList[(gridDataIndex + 3) % grid4DataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "m",
      //       grid5DataTypeList[(gridDataIndex + 4) % grid5DataTypeList.size()]
      //     );
      //     Properties.setValue(
      //       "o",
      //       grid6DataTypeList[(gridDataIndex + 5) % grid6DataTypeList.size()]
      //     );
      //   } else {
      //     gridDataIndex = 0;
      //   }
      //   onSettingsChanged();
      // }
    
  • I have a few problems with that:
    1. I only have 1 pair of eyes and almost 100 device types * 2-3 screens * at least 2-3 different data field layouts

    2. this adds lot of code, so this won't be possible to test the old devices that don't even have 20 bytes to spare :(

  • Well... I'm not a windows guy, so even if that would be added it wouldn't really help me Disappointed

    Maybe I'll open another feature-request... I'd like to be able to send commands on the cli interface of the simulator that can do things (but not only) like I have in the example at the beginning of this thread.