/// <summary> /// Initializes a new instance of the <see cref="TouchActions"/> class. /// </summary> /// <param name="driver">The <see cref="IWebDriver"/> object on which the actions built will be performed.</param> public TouchActions(IWebDriver driver) : base(driver) { IHasTouchScreen touchScreenDriver = driver as IHasTouchScreen; if (touchScreenDriver == null) { IWrapsDriver wrapper = driver as IWrapsDriver; while (wrapper != null) { touchScreenDriver = wrapper.WrappedDriver as IHasTouchScreen; if (touchScreenDriver != null) { break; } wrapper = wrapper.WrappedDriver as IWrapsDriver; } } if (touchScreenDriver == null) { throw new ArgumentException("The IWebDriver object must implement or wrap a driver that implements IHasTouchScreen.", "driver"); } this.touchScreen = touchScreenDriver.TouchScreen; }
public TouchActions(IWebDriver driver) : base(driver) { IHasTouchScreen hasTouchScreen = driver as IHasTouchScreen; if (hasTouchScreen == null) { for (IWrapsDriver wrapsDriver = driver as IWrapsDriver; wrapsDriver != null; wrapsDriver = (wrapsDriver.WrappedDriver as IWrapsDriver)) { hasTouchScreen = (wrapsDriver.WrappedDriver as IHasTouchScreen); if (hasTouchScreen != null) { break; } } } if (hasTouchScreen == null) { throw new ArgumentException("The IWebDriver object must implement or wrap a driver that implements IHasTouchScreen.", "driver"); } this.touchScreen = hasTouchScreen.TouchScreen; }