Selenium TouchActions is not working in c#

Viewed 62

I use Selenium 3.141.0 and ChromeDriver 78 and 99. My task is to test the mobile version of a website using touch actions.

I created a new class of ChromeDriver to support IHasTouchScreen

public class ChromeDriverWithTouchScreen : ChromeDriver, IHasTouchScreen
{
    public ITouchScreen TouchScreen => new RemoteTouchScreen(this);

    public ChromeDriverWithTouchScreen(ChromeOptions options) : base(options)
    {

    }
}

And i tried this:

var chromeOptions = new ChromeOptions();
chromeOptions.EnableMobileEmulation("iPhone X");
var chromeDriver = new ChromeDriverWithTouchScreen(chromeOptions);
chromeDriver.Navigate().GoToUrl("https://someUrl");

//in my real project i have any waits here
var element = chromeDriver.FindElement(By.XPath("//someButton"));

var touchActions = new TouchActions(chromeDriver);

touchActions.SingleTap(element).Perform();

And this code does nothing. The SingleTap method does not return any exceptions. The method works, but nothing happens on the screen.

I have tried different websites and different versions of Selenium and ChromeDriver but the result is the same

What am I doing wrong?

0 Answers
Related