Control Slice

The Control Slice is a control that represents a slice of a PageObject or a control. We can define controls not provided to us by the DOM or Automation to perform click interactions.

When to use

  • When it is not possible to make a selector for the desired control.

  • Match with an element that is dynamic but has the same appearance.

  • The element is on the screen but is not found on the DOM or desktop controls tree.

Scenario

Images on a canvas that the DOM or Automation can't provide. The blue rectangles are the ones that the DOM or Automation recognizes, and the red circles are candidates to control slices.

Desktop

Paint application with an image inside

Web

Web canvas with an element inside

How to use

The Control Slice can be used through the control interface IControlSlice that can be declared in multiple ways in the PageObject.

  • With an image.

    [Selector("MyContainerSelector", @"MyPath\MyImage.jpg")]
    public IControlSlice MyControlSlice { get; set; }
  • With a single point.

    [Selector("MyContainerSelector", 10, 30)]
    public IControlSlice MyControlSlice { get; set; }
  • With coordinates.

    [Selector("MyContainerSelector", 10, 30, 50, 80)]
    public IControlSlice MyControlSlice { get; set; }

Usage in code

myPageObject.MyControlSlice.Click();

Currently, only the click interactions will be sent to the control slice directly. Other interactions like SendKeys will be sent to the entire control.

Last updated

Was this helpful?