How to use TouchScroll class of WebDriverAPI package

Best WinAppDriver code snippet using WebDriverAPI.TouchScroll

TouchScroll.cs

Source:TouchScroll.cs Github

copy

Full Screen

...18using System.Threading;19namespace WebDriverAPI20{21 [TestClass]22 public class TouchScroll : AlarmClockBase23 {24 [ClassInitialize]25 public static void ClassInitialize(TestContext context)26 {27 Setup(context);28 }29 [ClassCleanup]30 public static void ClassCleanup()31 {32 TearDown();33 }34 [TestMethod]35 public void TouchScroll_Arbitrary()36 {37 var alarmPivotItem = session.FindElementByAccessibilityId("AlarmPivotItem");38 var stopwatchPivotItem = session.FindElementByAccessibilityId("StopwatchPivotItem");39 Assert.IsNotNull(alarmPivotItem);40 Assert.IsNotNull(stopwatchPivotItem);41 Assert.IsTrue(alarmPivotItem.Selected);42 Assert.IsFalse(stopwatchPivotItem.Selected);43 // Perform scroll right touch action to switch from Alarm tab to Stopwatch tab44 touchScreen.Scroll(100, 0);45 Thread.Sleep(TimeSpan.FromSeconds(1));46 Assert.IsFalse(alarmPivotItem.Selected);47 Assert.IsTrue(stopwatchPivotItem.Selected);48 // Perform scroll left touch action to scroll back from Stopwatch tab to Alarm tab49 touchScreen.Scroll(-100, 0);50 Thread.Sleep(TimeSpan.FromSeconds(1));51 Assert.IsTrue(alarmPivotItem.Selected);52 Assert.IsFalse(stopwatchPivotItem.Selected);53 }54 [TestMethod]55 public void TouchScrollOnElement_Horizontal()56 {57 var homePagePivot = session.FindElementByAccessibilityId("HomePagePivot");58 var alarmPivotItem = session.FindElementByAccessibilityId("AlarmPivotItem");59 var worldClockPivotItem = session.FindElementByAccessibilityId("WorldClockPivotItem");60 Assert.IsNotNull(homePagePivot);61 Assert.IsNotNull(alarmPivotItem);62 Assert.IsNotNull(worldClockPivotItem);63 Assert.IsTrue(alarmPivotItem.Selected);64 Assert.IsFalse(worldClockPivotItem.Selected);65 // Perform scroll left touch action to switch from Alarm tab to WorldClock tab66 touchScreen.Scroll(homePagePivot.Coordinates, -100, 0);67 Thread.Sleep(TimeSpan.FromSeconds(1));68 Assert.IsFalse(alarmPivotItem.Selected);69 Assert.IsTrue(worldClockPivotItem.Selected);70 // Perform scroll right touch action to scroll back from WorldClock tab to Alarm tab71 touchScreen.Scroll(homePagePivot.Coordinates, 100, 0);72 Thread.Sleep(TimeSpan.FromSeconds(1));73 Assert.IsTrue(alarmPivotItem.Selected);74 Assert.IsFalse(worldClockPivotItem.Selected);75 }76 [TestMethod]77 public void TouchScrollOnElement_Vertical()78 {79 // Navigate to add alarm page80 session.FindElementByAccessibilityId("AddAlarmButton").Click();81 session.FindElementByAccessibilityId("AlarmTimePicker").Click();82 Thread.Sleep(TimeSpan.FromSeconds(1));83 var minuteSelector = session.FindElementByAccessibilityId("MinuteLoopingSelector");84 var minute00 = session.FindElementByName("00");85 Assert.IsNotNull(minuteSelector);86 Assert.IsNotNull(minute00);87 Assert.IsTrue(minute00.Displayed);88 // Perform scroll down touch action to scroll the minute hiding 00 minutes that was shown89 touchScreen.Scroll(minuteSelector.Coordinates, 0, -55);90 Thread.Sleep(TimeSpan.FromSeconds(1));91 Assert.IsFalse(minute00.Displayed);92 // Perform scroll up touch action to scroll the the minute back showing 00 minutes that was hidden93 touchScreen.Scroll(minuteSelector.Coordinates, 0, 55);94 Thread.Sleep(TimeSpan.FromSeconds(1));95 Assert.IsTrue(minute00.Displayed);96 // Dismiss add alarm page97 DismissAddAlarmPage();98 }99 [TestMethod]100 public void TouchScrollOnElementError_StaleElement()101 {102 try103 {104 // Perform double tap touch on stale element105 touchScreen.Scroll(GetStaleElement().Coordinates, 0, 100);106 Assert.Fail("Exception should have been thrown");107 }108 catch (InvalidOperationException exception)109 {110 Assert.AreEqual(ErrorStrings.StaleElementReference, exception.Message);111 }112 }113 }114}...

Full Screen

Full Screen

TouchScroll

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using OpenQA.Selenium;7using OpenQA.Selenium.Remote;8using OpenQA.Selenium.Appium;9using OpenQA.Selenium.Appium.Android;10using OpenQA.Selenium.Appium.MultiTouch;11using OpenQA.Selenium.Appium.Interfaces;12using OpenQA.Selenium.Appium.Enums;13using OpenQA.Selenium.Appium.Service;14{15 {16 static void Main(string[] args)17 {18 AppiumOptions options = new AppiumOptions();19 options.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");20 options.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.0");21 options.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android Emulator");22 options.AddAdditionalCapability(MobileCapabilityType.BrowserName, "Chrome");23 options.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, 300);

Full Screen

Full Screen

TouchScroll

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using OpenQA.Selenium;7using OpenQA.Selenium.Appium;8using OpenQA.Selenium.Appium.Android;9using OpenQA.Selenium.Appium.MultiTouch;10using OpenQA.Selenium.Remote;11using OpenQA.Selenium.Appium.Interfaces;12using System.Threading;13using OpenQA.Selenium.Appium.Enums;14{15 {16 static void Main(string[] args)17 {18 DesiredCapabilities capabilities = new DesiredCapabilities();19 capabilities.SetCapability("deviceName", "Nexus 5");20 capabilities.SetCapability("platformName", "Android");21 capabilities.SetCapability("appPackage", "com.android.calculator2");22 capabilities.SetCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

TouchScroll

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using OpenQA.Selenium;7using OpenQA.Selenium.Remote;8using OpenQA.Selenium.Appium;9using OpenQA.Selenium.Appium.Android;10using OpenQA.Selenium.Appium.MultiTouch;11{12 {13 static void Main(string[] args)14 {15 AppiumServer appiumServer = new AppiumServer();16 appiumServer.StartServer();

Full Screen

Full Screen

TouchScroll

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using OpenQA.Selenium;7using OpenQA.Selenium.Appium;8using OpenQA.Selenium.Appium.Android;9using OpenQA.Selenium.Appium.MultiTouch;10using OpenQA.Selenium.Remote;11{12 {13 static void Main(string[] args)14 {15 AppiumOptions options = new AppiumOptions();16 options.AddAdditionalCapability("platformName", "Android");17 options.AddAdditionalCapability("deviceName", "emulator-5554");18 options.AddAdditionalCapability("app", @"C:\Users\shubham.kumar\Downloads\com.androidsample.generalstore.apk");

Full Screen

Full Screen

TouchScroll

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using OpenQA.Selenium;7using OpenQA.Selenium.Firefox;8using OpenQA.Selenium.Support.UI;9using OpenQA.Selenium.Interactions;10using WebDriverAPI;11{12 {13 static void Main(string[] args)14 {15 IWebDriver driver = new FirefoxDriver();16 driver.Manage().Window.Maximize();17 TouchScroll touchScroll = new TouchScroll(driver);18 touchScroll.ScrollDown(500);19 touchScroll.ScrollUp(500);20 touchScroll.ScrollLeft(500);21 touchScroll.ScrollRight(500);22 driver.Quit();23 }24 }25}26using System;27using System.Collections.Generic;28using System.Linq;29using System.Text;30using System.Threading.Tasks;31using OpenQA.Selenium;32using OpenQA.Selenium.Firefox;33using OpenQA.Selenium.Support.UI;34using OpenQA.Selenium.Interactions;35using WebDriverAPI;36{37 {38 static void Main(string[] args)39 {40 IWebDriver driver = new FirefoxDriver();41 driver.Manage().Window.Maximize();42 TouchSwipe touchSwipe = new TouchSwipe(driver);43 touchSwipe.SwipeLeft(500);44 touchSwipe.SwipeRight(500);45 touchSwipe.SwipeUp(500);46 touchSwipe.SwipeDown(500);47 driver.Quit();48 }49 }50}51using System;52using System.Collections.Generic;53using System.Linq;54using System.Text;55using System.Threading.Tasks;56using OpenQA.Selenium;57using OpenQA.Selenium.Firefox;58using OpenQA.Selenium.Support.UI;59using OpenQA.Selenium.Interactions;60using WebDriverAPI;61{62 {63 static void Main(string[] args)64 {65 IWebDriver driver = new FirefoxDriver();66 driver.Manage().Window.Maximize();67 TouchPinch touchPinch = new TouchPinch(driver);68 touchPinch.PinchIn(500);69 touchPinch.PinchOut(500);70 driver.Quit();

Full Screen

Full Screen

TouchScroll

Using AI Code Generation

copy

Full Screen

1using OpenQA.Selenium;2using OpenQA.Selenium.Appium;3using OpenQA.Selenium.Appium.Android;4using OpenQA.Selenium.Appium.MultiTouch;5using OpenQA.Selenium.Remote;6using System;7using WebDriverAPI;8using System.Threading;9{10 {11 static void Main(string[] args)12 {13 AppiumOptions options = new AppiumOptions();14 options.AddAdditionalCapability("deviceName", "emulator-5554");15 options.AddAdditionalCapability("platformName", "Android");16 options.AddAdditionalCapability("appPackage", "com.android.calculator2");17 options.AddAdditionalCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

TouchScroll

Using AI Code Generation

copy

Full Screen

1using WebDriverAPI;2{3 {4 static void Main(string[] args)5 {6 ChromeDriver driver = new ChromeDriver();7 driver.Manage().Window.Maximize();8 driver.SwitchTo().Frame("iframeResult");9 TouchScroll touchScroll = new TouchScroll();10 touchScroll.ScrollDown(driver);11 touchScroll.ScrollUp(driver);12 touchScroll.ScrollLeft(driver);13 touchScroll.ScrollRight(driver);14 driver.Quit();15 }16 }17}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run WinAppDriver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful