Touch events

This page has been translated automatically

We want to provide you with the latest help content in your language as soon as possible. This page has been translated automatically and may contain grammatical errors or inaccuracies. We want this content to be useful to you. Please let us know at the bottom of this page if this information was helpful.

View the original article in Russian: Touch-события

Starting with version 7.1.4.0, a Touch property with a set of methods has been added to the CommandCenter.Tab. The Touch property has basic methods: TouchStart , TouchEnd , TouchMove , TouchCancel , as well as complex methods with Touch overloads, SwipeIntoView , SwipeBetween and others.

This is only the first stage of implementing touch events in the Chrome browser, so for now they are only available from C # code. In the next versions, control from the interface will be implemented.

Examples of

Emulation of touch-pressing

var tab = instance.ActiveTab; var init = tab.FindElementByXPath("/html/body/button", 0); // Ищем HTML элемент через XPath tab.Touch.Touch(init); // Жмём по нему

 


Scrolling

var tab = instance.ActiveTab; HtmlElement init = tab.FindElementByXPath(".//button", 0); // Ищем HTML элемент через XPath tab.Touch.SwipeIntoView(init); // Скроллим экран тачами до нужного HTML элемента

 


Swipe right

var tab = instance.ActiveTab; // Будем делать свайп внутри HTML элемента. Составим XPath выражение. var canvas = tab.FindElementByXPath(@"//*[@id=""canvas""]", 0); // Получаем его размеры: ширину и высоту var width = canvas.BoundingClientWidth; var height = canvas.BoundingClientHeight; // Определяем координаты первого касания по оси X, и последнего - когда отпускаем палец var offsetX = width / 4; var minX = canvas.DisplacementInBrowser.X + offsetX; var maxX = minX + width - 2*offsetX; // Определяем координаты первого касания по оси Y, и последнего - когда отпускаем палец var offsetY = height / 4; var minY = canvas.DisplacementInBrowser.Y + offsetY; var maxY = minY; // Делаем свайп вправо tab.Touch.SwipeBetween(minX, minY, maxX, maxY);

Settings

By default, a number of parameters are taken into account and randomized: speed, acceleration, motion curve, and others. All movements will be as natural as possible out of the box, but if you need to make adjustments to the behavior of touch events, there is such a possibility too.

 

Demonstration project

Download