locked
How to assign AutomationIDs to Metro tile elements? RRS feed

  • Question

  • I want to assign AutomationID to the metro tile of a metro app which is developed using HTML5/JavaScript.

    My observation is that, if no automationID is assigned, the same is computed using the following attributes from package.appxmanifest -

    AutomationID = <Identity Name>_<hash of Identity Publisher>!<Application Id>

    which is the same as:

    AutomationID = <Pacakage Family Name>!<Application Id>

    Can anyone tell me whether AutomationID is computed like this always? And is there any way to assign a different value to it? I know that we can assign AutomationID if we develop the metro app using C# by assigning a value to AutomationProperties.AutomationID in the xaml file. But is there a way to do the same when we develop the metro app using JavaScript?

    Below is a sample package.appxmanifest in which the above mentioned attributes are highlighted in Bold:

    <?xml version="1.0" encoding="utf-8"?>
    <Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
      <Identity Name="Microsoft.SDKSamples.AppSettings.JS" Version="1.0.0.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
      <Properties>
        <DisplayName>App settings SDK Sample</DisplayName>
        <PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
        <Description>FeatureName SDK Sample</Description>
        <Logo>images\storeLogo-sdk.png</Logo>
      </Properties>
      <Prerequisites>
        <OSMinVersion>6.2</OSMinVersion>
        <OSMaxVersionTested>6.2</OSMaxVersionTested>
      </Prerequisites>
      <Resources>
        <Resource Language="en-US" />
      </Resources>
      <Applications>
        <Application Id="App" StartPage="default.html">
          <VisualElements DisplayName="App settings SDK sample" Logo="images\squareTile-sdk.png" SmallLogo="images\smallTile-sdk.png" Description="This sample demonstrates how to use the Settings flyout to integrate an app's settings UI with the Settings charm." ForegroundText="dark" BackgroundColor="#FFFFFF">
            <DefaultTile ShortName="App settings" ShowName="allLogos" WideLogo="images\tile-sdk.png" />
            <SplashScreen BackgroundColor="white" Image="images\splash-sdk.png" />
            <InitialRotationPreference>
              <Rotation Preference="landscape" />
            </InitialRotationPreference>
          </VisualElements>
        </Application>
      </Applications>
      <Capabilities>
        <Capability Name="musicLibrary" />
        <Capability Name="picturesLibrary" />
        <Capability Name="documentsLibrary" />
        <Capability Name="internetClient" />
        <DeviceCapability Name="location" />
      </Capabilities>
    </Package>

    --

    Thanks,

    Venkatram

    Thursday, May 10, 2012 10:32 AM

Answers

  • Hi Venkatram,

    I was able to confirm with the product team "For tiles for Metro style apps the Automation ID will always be equal to the AppUserModelId"


    Jeff Sanders (MSFT)

    Wednesday, May 16, 2012 12:13 PM
    Moderator

All replies

  • Hi Venkatram,

    Not that I know of.  Why do you need to do this?

    -Jeff


    Jeff Sanders (MSFT)

    Thursday, May 10, 2012 6:59 PM
    Moderator
  • Hi Jeff,

    Assigning AutomationID helps us in automating tests. It is easier to identify the elements through AutomationID as all other attributes (class name, framework ID etc.) are same for all the metro tiles. By using "inspect", we can get the value of each of these attributes.

    --

    Thanks,

    Venkatram

    Friday, May 11, 2012 5:03 AM
  • Hi Venkatram,

    I was able to confirm with the product team "For tiles for Metro style apps the Automation ID will always be equal to the AppUserModelId"


    Jeff Sanders (MSFT)

    Wednesday, May 16, 2012 12:13 PM
    Moderator
  • Thanks Jeff for the confirmation.
    Monday, May 21, 2012 5:49 AM
  • How do you automate tests? Do you have a solution that can start a metro app with different contracts than the launch contract (via IActivationManager)?
    Monday, May 21, 2012 6:24 AM
  • Hi Phil,

    I don't know if this is going to help you. This is how I'm trying to automate tests for metro app -

    1) Get the AutomationID of the metro app tile using inspect.

    2) Identify the element using the above ID and use InvokePattern to launch the app. More about InvokePattern and AutomationElement can be found here -

    Automation Element: http://msdn.microsoft.com/en-us/library/ms752331.aspx

    Control Patterns: http://msdn.microsoft.com/en-us/library/ms752362

    --

    Thanks,

    Venkatram

    Monday, May 21, 2012 10:33 AM
  • Thanks! Since I am using JS and not C# I cannot use any of the things you mentioned.

    But can you describe how you start the app in the first place, or is the automation framework doing that for you?


    Monday, May 21, 2012 11:40 AM
  • The app is launched by the framework. The windows automation API provides a method to launch an app using the Automation ID property. 
    Monday, May 21, 2012 12:18 PM
  • Ok, there is no such thing in JS metro apps.

    I am using a custom app runner that starts the app from the command line and performs UI/Unit tests using jasmine and cucumber.

    Monday, May 21, 2012 12:52 PM