Silk4J enables you to surpass these challenges and to click the appropriate object on a mobile website.
When recording a test on a mobile device, Silk4J 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. Silk4J 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, Silk4J 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, Silk4J scrolls to the appropriate location in the website.
The following code shows how you can test a DomButton with a fixed size of 100 x 20 px in your HTML page.
DomButton domButton = desktop.find("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. Silk4J clicks in the middle of the element when using the code above, independent of the current zoom factor, because Silk4J interprets the coordinates as HTML coordinates and applies the current zoom factor.