Clicking on Objects in a Mobile Website

When clicking on an object during the recording and replay of an automated test, a mobile website presents the following challenges in comparison to a desktop website:
  • Varying zoom factors and device pixel ratios.
  • Varying screen sizes for different mobile devices.
  • Varying font and graphic sizes between mobile devices, usually smaller in comparison to a website in a desktop browser.
  • Varying pixel size and resolution for different mobile devices.

Silk Test Workbench enables you to surpass these challenges and to click the appropriate object on a mobile website.

When recording a test on a mobile device, Silk Test Workbench does not record coordinates when recording a Click. However, for cross-browser testing, coordinates are allowed during replay. You can also manually add coordinates to a Click. Silk Test Workbench interprets these coordinates as the HTML coordinates of the object. To click on the appropriate object inside the BrowserWindow, during the replay of a test on a mobile device, Silk Test Workbench applies the current zoom factor to the HTML coordinates of the object. The device pixel coordinates are the HTML coordinates of the object, multiplied with the current zoom factor.

If the object is not visible in the currently displayed section of the mobile website, Silk Test Workbench scrolls to the appropriate location in the website.

Example

The following code shows how you can test a DomButton with a fixed size of 100 x 20 px in your HTML page.

VB
DomButton domButton = _desktop.Find(Of DomButton)("locator for the button");
domButton.Click(MouseButton.LEFT, new Point(50, 10));

During replay on a different mobile device or with a different zoom factor, the DomButton might for example have an actual width of 10px on the device screen. Silk Test Workbench clicks in the middle of the element when using the code above, independent of the current zoom factor, because Silk Test Workbench interprets the coordinates as HTML coordinates and applies the current zoom factor.