How to use MoveAsync method of PuppeteerSharp.Input.Mouse class

Best Puppeteer-sharp code snippet using PuppeteerSharp.Input.Mouse.MoveAsync

PageServer.cs

Source:PageServer.cs Github

copy

Full Screen

...453 smallmap.Dispose();454 var list = cv.GetPoints2(Rsct);455 var slider = await page.WaitForXPathAsync("//div[@class='sp_msg']/img");456 var box = await slider.BoundingBoxAsync();457 await page.Mouse.MoveAsync(box.X, box.Y);458 await page.Mouse.DownAsync();459 Random r = new Random(Guid.NewGuid().GetHashCode());460 var Steps = r.Next(5, 15);461 foreach (var item in list)462 {463 await page.Mouse.MoveAsync(item.X, box.Y, new PuppeteerSharp.Input.MoveOptions { Steps = Steps });464 }465 await page.Mouse.UpAsync();466 await page.WaitForTimeoutAsync(1000);467 var html = await page.GetContentAsync();468 469 ResultModel<object> result = ResultModel<object>.Create(false, "");470 if (html.Contains("重新获取"))471 {472 Console.WriteLine("验证成功");473 result.success = true;474 }475 else476 {477 if (html.Contains("短信验证码发送次数已达上限"))...

Full Screen

Full Screen

PuppeteerWebAutomationFrameworkInstance.cs

Source:PuppeteerWebAutomationFrameworkInstance.cs Github

copy

Full Screen

...82 var javascriptScope = _domTunnel.DeclareScope(this);83 try84 {85 var dataTransferObjectVariableName = await javascriptScope.CreateNewVariableAsync("new DataTransfer()");86 await _page.Mouse.MoveAsync(87 (from.BoundingClientRectangle.Left + fromOffsetX) ?? from.BoundingClientRectangle.Center.X,88 (from.BoundingClientRectangle.Top + fromOffsetY) ?? from.BoundingClientRectangle.Center.Y);89 await _page.Mouse.DownAsync();90 await _domTunnel.DispatchDomElementDragEventAsync(91 this,92 from,93 "dragstart",94 dataTransferObjectVariableName);95 await _domTunnel.DispatchDomElementDragEventAsync(96 this,97 from,98 "drag",99 dataTransferObjectVariableName);100 await _page.Mouse.MoveAsync(101 (to.BoundingClientRectangle.Left + toOffsetX) ?? to.BoundingClientRectangle.Center.X,102 (to.BoundingClientRectangle.Top + toOffsetY) ?? to.BoundingClientRectangle.Center.Y);103 await _domTunnel.DispatchDomElementDragEventAsync(104 this,105 to,106 "dragenter",107 dataTransferObjectVariableName);108 await _domTunnel.DispatchDomElementDragEventAsync(109 this,110 to,111 "dragover",112 dataTransferObjectVariableName);113 await _domTunnel.DispatchDomElementDragEventAsync(114 this,115 from,116 "drag",117 dataTransferObjectVariableName);118 await _page.Mouse.UpAsync();119 await _domTunnel.DispatchDomElementDragEventAsync(120 this,121 to,122 "dragleave",123 dataTransferObjectVariableName);124 await _domTunnel.DispatchDomElementDragEventAsync(125 this,126 from,127 "dragend",128 dataTransferObjectVariableName);129 await _domTunnel.DispatchDomElementDragEventAsync(130 this,131 to,132 "drop",133 dataTransferObjectVariableName);134 }135 finally136 {137 await javascriptScope.DeleteAllVariablesAsync();138 }139 }140 public async Task EnterTextInAsync(IReadOnlyList<IDomElement> elements, string text)141 {142 var handles = await GetElementHandlesFromDomElementsAsync(elements);143 foreach (var handle in handles)144 {145 await handle.TypeAsync(text);146 }147 }148 public async Task<string> EvaluateJavaScriptExpressionAsync(string code)149 {150 while (true)151 {152 try153 {154 while (IsNavigating)155 await Task.Delay(100);156 var blob = await _page.EvaluateExpressionAsync(code);157 return blob?.ToString();158 }159 catch (PuppeteerException)160 {161 if(!IsNavigating)162 throw;163 }164 }165 }166 public async Task<IReadOnlyList<IDomElement>> FindDomElementsBySelectorAsync(int methodChainOffset, string selector)167 {168 if (_isDisposed)169 return new List<IDomElement>();170 return await _domTunnel.GetDomElementsFromSelector(this,171 methodChainOffset,172 selector);173 }174 public async Task FocusAsync(IDomElement domElement)175 {176 var handle = await GetElementHandleFromDomElementAsync(domElement);177 await handle.FocusAsync();178 //there is a bug causing Puppeteer to not focus input elements properly - so we invoke their onfocus events manually.179 if (domElement.TagName == "INPUT" && domElement.Attributes["type"] == "text")180 {181 await _domTunnel.DispatchDomElementFocusEventAsync(182 this,183 domElement,184 "focus");185 }186 }187 private async Task<ElementHandle> GetElementHandleFromDomElementAsync(IDomElement domElement)188 {189 return await _page.QuerySelectorAsync(domElement.CssSelector);190 }191 public async Task HoverAsync(IDomElement domElement, int? offsetX, int? offsetY)192 {193 await _page.Mouse.MoveAsync(194 (domElement.BoundingClientRectangle.Left + offsetX) ?? domElement.BoundingClientRectangle.Center.X,195 (domElement.BoundingClientRectangle.Top + offsetY) ?? domElement.BoundingClientRectangle.Center.Y);196 }197 public async Task InitializeAsync()198 {199 _browser = await _driverConstructor();200 var pages = await _browser.PagesAsync();201 _page = pages.Single();202 await _page.SetCacheEnabledAsync(false);203 _page.Request += PageRequest;204 _page.RequestFinished += PageRequestFinished;205 _page.RequestFailed += PageRequestFinished;206 }207 private void PageRequestFinished(object sender, RequestEventArgs e)...

Full Screen

Full Screen

Index.cshtml.cs

Source:Index.cshtml.cs Github

copy

Full Screen

...76 var rect = await slideBtn.BoundingBoxAsync();77 var left = rect.X + 10;78 var top = rect.Y + 10;79 var mouse = page.Mouse;80 await mouse.MoveAsync(left, top);81 await page.Touchscreen.TapAsync(left, top);82 await mouse.DownAsync();83 var startTime = DateTime.Now;84 await mouse.MoveAsync(left + 800, top, new PuppeteerSharp.Input.MoveOptions { Steps = 30 });85 await page.Touchscreen.TapAsync(left + 800, top);86 Console.WriteLine(DateTime.Now - startTime);87 await mouse.UpAsync();88 var success = await page.WaitForSelectorAsync(".yes", new WaitForSelectorOptions { Timeout = 3000 });89 string content = await page.GetContentAsync();90 91 var parser = new HtmlParser();92 var document = await parser.ParseDocumentAsync(content);93 aliToken = (document.GetElementById("aliToken") as IHtmlInputElement).GetAttribute("sms");94 aliSessionId = (document.GetElementById("aliSessionId") as IHtmlInputElement).GetAttribute("sms");95 aliSig = (document.GetElementById("aliSig") as IHtmlInputElement).GetAttribute("sms");96 }97 var response = await "https://upay.10010.com/npfwap/NpfMob/needdubbo/needDubboCheck?phoneNo=13113075869&amountMoney=200&channelKey=wxgz"98 .WithHeaders(new { Referer = "https://upay.10010.com/jf_wxgz" })...

Full Screen

Full Screen

MouseTests.cs

Source:MouseTests.cs Github

copy

Full Screen

...56 {57 await Page.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");58 var dimensions = await Page.EvaluateFunctionAsync<Dimensions>(Dimensions);59 var mouse = Page.Mouse;60 await mouse.MoveAsync(dimensions.X + dimensions.Width - 4, dimensions.Y + dimensions.Height - 4);61 await mouse.DownAsync();62 await mouse.MoveAsync(dimensions.X + dimensions.Width + 100, dimensions.Y + dimensions.Height + 100);63 await mouse.UpAsync();64 var newDimensions = await Page.EvaluateFunctionAsync<Dimensions>(Dimensions);65 Assert.Equal(Math.Round(dimensions.Width + 104, MidpointRounding.AwayFromZero), newDimensions.Width);66 Assert.Equal(Math.Round(dimensions.Height + 104, MidpointRounding.AwayFromZero), newDimensions.Height);67 }68 [PuppeteerTest("mouse.spec.ts", "Mouse", "should select the text with mouse")]69 [SkipBrowserFact(skipFirefox: true)]70 public async Task ShouldSelectTheTextWithMouse()71 {72 await Page.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");73 await Page.FocusAsync("textarea");74 const string text = "This is the text that we are going to try to select. Let's see how it goes.";75 await Page.Keyboard.TypeAsync(text);76 // Firefox needs an extra frame here after typing or it will fail to set the scrollTop77 await Page.EvaluateExpressionAsync("new Promise(requestAnimationFrame)");78 await Page.EvaluateExpressionAsync("document.querySelector('textarea').scrollTop = 0");79 var dimensions = await Page.EvaluateFunctionAsync<Dimensions>(Dimensions);80 await Page.Mouse.MoveAsync(dimensions.X + 2, dimensions.Y + 2);81 await Page.Mouse.DownAsync();82 await Page.Mouse.MoveAsync(100, 100);83 await Page.Mouse.UpAsync();84 Assert.Equal(text, await Page.EvaluateFunctionAsync<string>(@"() => {85 const textarea = document.querySelector('textarea');86 return textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);87 }"));88 }89 [PuppeteerTest("mouse.spec.ts", "Mouse", "should trigger hover state")]90 [SkipBrowserFact(skipFirefox: true)]91 public async Task ShouldTriggerHoverState()92 {93 await Page.GoToAsync(TestConstants.ServerUrl + "/input/scrollable.html");94 await Page.HoverAsync("#button-6");95 Assert.Equal("button-6", await Page.EvaluateExpressionAsync<string>("document.querySelector('button:hover').id"));96 await Page.HoverAsync("#button-2");97 Assert.Equal("button-2", await Page.EvaluateExpressionAsync<string>("document.querySelector('button:hover').id"));98 await Page.HoverAsync("#button-91");99 Assert.Equal("button-91", await Page.EvaluateExpressionAsync<string>("document.querySelector('button:hover').id"));100 }101 [PuppeteerTest("mouse.spec.ts", "Mouse", "should trigger hover state with removed window.Node")]102 [SkipBrowserFact(skipFirefox: true)]103 public async Task ShouldTriggerHoverStateWithRemovedWindowNode()104 {105 await Page.GoToAsync(TestConstants.ServerUrl + "/input/scrollable.html");106 await Page.EvaluateExpressionAsync("delete window.Node");107 await Page.HoverAsync("#button-6");108 Assert.Equal("button-6", await Page.EvaluateExpressionAsync("document.querySelector('button:hover').id"));109 }110 [PuppeteerTest("mouse.spec.ts", "Mouse", "should set modifier keys on click")]111 [SkipBrowserFact(skipFirefox: true)]112 public async Task ShouldSetModifierKeysOnClick()113 {114 await Page.GoToAsync(TestConstants.ServerUrl + "/input/scrollable.html");115 await Page.EvaluateExpressionAsync("document.querySelector('#button-3').addEventListener('mousedown', e => window.lastEvent = e, true)");116 var modifiers = new Dictionary<string, string> { ["Shift"] = "shiftKey", ["Control"] = "ctrlKey", ["Alt"] = "altKey", ["Meta"] = "metaKey" };117 foreach (var modifier in modifiers)118 {119 await Page.Keyboard.DownAsync(modifier.Key);120 await Page.ClickAsync("#button-3");121 if (!(await Page.EvaluateFunctionAsync<bool>("mod => window.lastEvent[mod]", modifier.Value)))122 {123 Assert.True(false, $"{modifier.Value} should be true");124 }125 await Page.Keyboard.UpAsync(modifier.Key);126 }127 await Page.ClickAsync("#button-3");128 foreach (var modifier in modifiers)129 {130 if (await Page.EvaluateFunctionAsync<bool>("mod => window.lastEvent[mod]", modifier.Value))131 {132 Assert.False(true, $"{modifiers.Values} should be false");133 }134 }135 }136 [PuppeteerTest("mouse.spec.ts", "Mouse", "should send mouse wheel events")]137 [SkipBrowserFact(skipFirefox: true)]138 public async Task ShouldSendMouseWheelEvents()139 {140 await Page.GoToAsync(TestConstants.ServerUrl + "/input/wheel.html");141 var elem = await Page.QuerySelectorAsync("div");142 var boundingBoxBefore = await elem.BoundingBoxAsync();143 Assert.Equal(115, boundingBoxBefore.Width);144 Assert.Equal(115, boundingBoxBefore.Height);145 await Page.Mouse.MoveAsync(146 boundingBoxBefore.X + (boundingBoxBefore.Width / 2),147 boundingBoxBefore.Y + (boundingBoxBefore.Height / 2)148 );149 await Page.Mouse.WheelAsync(0, -100);150 var boundingBoxAfter = await elem.BoundingBoxAsync();151 Assert.Equal(230, boundingBoxAfter.Width);152 Assert.Equal(230, boundingBoxAfter.Height);153 }154 [PuppeteerTest("mouse.spec.ts", "Mouse", "should tween mouse movement")]155 [SkipBrowserFact(skipFirefox: true)]156 public async Task ShouldTweenMouseMovement()157 {158 await Page.Mouse.MoveAsync(100, 100);159 await Page.EvaluateExpressionAsync(@"{160 window.result = [];161 document.addEventListener('mousemove', event => {162 window.result.push([event.clientX, event.clientY]);163 });164 }");165 await Page.Mouse.MoveAsync(200, 300, new MoveOptions { Steps = 5 });166 Assert.Equal(new[] {167 new[]{ 120, 140 },168 new[]{ 140, 180 },169 new[]{ 160, 220 },170 new[]{ 180, 260 },171 new[]{ 200, 300 }172 }, await Page.EvaluateExpressionAsync<int[][]>("result"));173 }174 [PuppeteerTest("mouse.spec.ts", "Mouse", "should work with mobile viewports and cross process navigations")]175 [SkipBrowserFact(skipFirefox: true)]176 public async Task ShouldWorkWithMobileViewportsAndCrossProcessNavigations()177 {178 await Page.GoToAsync(TestConstants.EmptyPage);179 await Page.SetViewportAsync(new ViewPortOptions...

Full Screen

Full Screen

WebScraper.cs

Source:WebScraper.cs Github

copy

Full Screen

...161 MoveMouseAsync(x, y).Wait();162 }163 private async Task MoveMouseAsync(decimal x, decimal y)164 {165 await m_page.Mouse.MoveAsync(x, y);166 m_MouseX = x;167 m_MouseY = y;168 }169 /// <summary>170 /// Simulates a mouse click on page.171 /// </summary>172 /// <param name="button">Mouse button to simulate.</param>173 public void MouseClick(MouseButton button)174 {175 MouseClickAsync(button).Wait();176 }177 private async Task MouseClickAsync(MouseButton button)178 {179 await m_page.Mouse.ClickAsync(m_MouseX, m_MouseY, new ClickOptions{ Button = button == MouseButton.Left ? PuppeteerSharp.Input.MouseButton.Left : PuppeteerSharp.Input.MouseButton.Right });...

Full Screen

Full Screen

InputTests.cs

Source:InputTests.cs Github

copy

Full Screen

...26 public async Task ShouldNotHangWithTouchEnabledViewports()27 {28 await Page.SetViewportAsync(TestConstants.IPhone.ViewPort);29 await Page.Mouse.DownAsync();30 await Page.Mouse.MoveAsync(100, 10);31 await Page.Mouse.UpAsync();32 }33 [Fact]34 public async Task ShouldUploadTheFile()35 {36 await Page.GoToAsync(TestConstants.ServerUrl + "/input/fileupload.html");37 var filePath = TestConstants.FileToUpload;38 var input = await Page.QuerySelectorAsync("input");39 await input.UploadFileAsync(filePath);40 Assert.Equal("file-to-upload.txt", await Page.EvaluateFunctionAsync<string>("e => e.files[0].name", input));41 Assert.Equal("contents of the file", await Page.EvaluateFunctionAsync<string>(@"e => {42 const reader = new FileReader();43 const promise = new Promise(fulfill => reader.onload = fulfill);44 reader.readAsText(e.files[0]);45 return promise.then(() => reader.result);46 }", input));47 }48 [Fact]49 public async Task ShouldResizeTheTextarea()50 {51 await Page.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");52 var dimensions = await Page.EvaluateFunctionAsync<Dimensions>(Dimensions);53 var mouse = Page.Mouse;54 await mouse.MoveAsync(dimensions.X + dimensions.Width - 4, dimensions.Y + dimensions.Height - 4);55 await mouse.DownAsync();56 await mouse.MoveAsync(dimensions.X + dimensions.Width + 100, dimensions.Y + dimensions.Height + 100);57 await mouse.UpAsync();58 var newDimensions = await Page.EvaluateFunctionAsync<Dimensions>(Dimensions);59 Assert.Equal(Math.Round(dimensions.Width + 104, MidpointRounding.AwayFromZero), newDimensions.Width);60 Assert.Equal(Math.Round(dimensions.Height + 104, MidpointRounding.AwayFromZero), newDimensions.Height);61 }62 [Fact]63 public async Task ShouldSelectTheTextWithMouse()64 {65 await Page.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");66 await Page.FocusAsync("textarea");67 const string text = "This is the text that we are going to try to select. Let's see how it goes.";68 await Page.Keyboard.TypeAsync(text);69 // Firefox needs an extra frame here after typing or it will fail to set the scrollTop70 await Page.EvaluateExpressionAsync("new Promise(requestAnimationFrame)");71 await Page.EvaluateExpressionAsync("document.querySelector('textarea').scrollTop = 0");72 var dimensions = await Page.EvaluateFunctionAsync<Dimensions>(Dimensions);73 await Page.Mouse.MoveAsync(dimensions.X + 2, dimensions.Y + 2);74 await Page.Mouse.DownAsync();75 await Page.Mouse.MoveAsync(100, 100);76 await Page.Mouse.UpAsync();77 Assert.Equal(text, await Page.EvaluateFunctionAsync<string>(@"() => {78 const textarea = document.querySelector('textarea');79 return textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);80 }"));81 }82 [Fact]83 public async Task ShouldTriggerHoverState()84 {85 await Page.GoToAsync(TestConstants.ServerUrl + "/input/scrollable.html");86 await Page.HoverAsync("#button-6");87 Assert.Equal("button-6", await Page.EvaluateExpressionAsync<string>("document.querySelector('button:hover').id"));88 await Page.HoverAsync("#button-2");89 Assert.Equal("button-2", await Page.EvaluateExpressionAsync<string>("document.querySelector('button:hover').id"));90 await Page.HoverAsync("#button-91");91 Assert.Equal("button-91", await Page.EvaluateExpressionAsync<string>("document.querySelector('button:hover').id"));92 }93 [Fact]94 public async Task ShouldTriggerHoverStateWithRemovedWindowNode()95 {96 await Page.GoToAsync(TestConstants.ServerUrl + "/input/scrollable.html");97 await Page.EvaluateExpressionAsync("delete window.Node");98 await Page.HoverAsync("#button-6");99 Assert.Equal("button-6", await Page.EvaluateExpressionAsync("document.querySelector('button:hover').id"));100 }101 [Fact]102 public async Task ShouldSetModifierKeysOnClick()103 {104 await Page.GoToAsync(TestConstants.ServerUrl + "/input/scrollable.html");105 await Page.EvaluateExpressionAsync("document.querySelector('#button-3').addEventListener('mousedown', e => window.lastEvent = e, true)");106 var modifiers = new Dictionary<string, string> { ["Shift"] = "shiftKey", ["Control"] = "ctrlKey", ["Alt"] = "altKey", ["Meta"] = "metaKey" };107 foreach (var modifier in modifiers)108 {109 await Page.Keyboard.DownAsync(modifier.Key);110 await Page.ClickAsync("#button-3");111 if (!(await Page.EvaluateFunctionAsync<bool>("mod => window.lastEvent[mod]", modifier.Value)))112 {113 Assert.True(false, $"{modifier.Value} should be true");114 }115 await Page.Keyboard.UpAsync(modifier.Key);116 }117 await Page.ClickAsync("#button-3");118 foreach (var modifier in modifiers)119 {120 if (await Page.EvaluateFunctionAsync<bool>("mod => window.lastEvent[mod]", modifier.Value))121 {122 Assert.False(true, $"{modifiers.Values} should be false");123 }124 }125 }126 [Fact]127 public async Task ShouldTweenMouseMovement()128 {129 await Page.Mouse.MoveAsync(100, 100);130 await Page.EvaluateExpressionAsync(@"{131 window.result = [];132 document.addEventListener('mousemove', event => {133 window.result.push([event.clientX, event.clientY]);134 });135 }");136 await Page.Mouse.MoveAsync(200, 300, new MoveOptions { Steps = 5 });137 Assert.Equal(new[] {138 new[]{ 120, 140 },139 new[]{ 140, 180 },140 new[]{ 160, 220 },141 new[]{ 180, 260 },142 new[]{ 200, 300 }143 }, await Page.EvaluateExpressionAsync<int[][]>("result"));144 }145 [Fact]146 public async Task ShouldWorkWithMobileViewportsAndCrossProcessNavigations()147 {148 await Page.GoToAsync(TestConstants.EmptyPage);149 await Page.SetViewportAsync(new ViewPortOptions150 {...

Full Screen

Full Screen

Mouse.cs

Source:Mouse.cs Github

copy

Full Screen

...28 /// <param name="x"></param>29 /// <param name="y"></param>30 /// <param name="options"></param>31 /// <returns>Task</returns>32 public async Task MoveAsync(decimal x, decimal y, MoveOptions options = null)33 {34 options = options ?? new MoveOptions();35 decimal fromX = _x;36 decimal fromY = _y;37 _x = x;38 _y = y;39 int steps = options.Steps;40 for (var i = 1; i <= steps; i++)41 {42 await _client.SendAsync("Input.dispatchMouseEvent", new InputDispatchMouseEventRequest43 {44 Type = MouseEventType.MouseMoved,45 Button = _button,46 X = fromX + ((_x - fromX) * ((decimal)i / steps)),47 Y = fromY + ((_y - fromY) * ((decimal)i / steps)),48 Modifiers = _keyboard.Modifiers49 }).ConfigureAwait(false);50 }51 }52 /// <summary>53 /// Shortcut for <see cref="MoveAsync(decimal, decimal, MoveOptions)"/>, <see cref="DownAsync(ClickOptions)"/> and <see cref="UpAsync(ClickOptions)"/>54 /// </summary>55 /// <param name="x"></param>56 /// <param name="y"></param>57 /// <param name="options"></param>58 /// <returns>Task</returns>59 public async Task ClickAsync(decimal x, decimal y, ClickOptions options = null)60 {61 options = options ?? new ClickOptions();62 if (options.Delay > 0)63 {64 await Task.WhenAll(65 MoveAsync(x, y),66 DownAsync(options)67 ).ConfigureAwait(false);68 await Task.Delay(options.Delay).ConfigureAwait(false);69 await UpAsync(options).ConfigureAwait(false);70 }71 else72 {73 await Task.WhenAll(74 MoveAsync(x, y),75 DownAsync(options),76 UpAsync(options)77 ).ConfigureAwait(false);78 }79 }80 /// <summary>81 /// Dispatches a <c>mousedown</c> event.82 /// </summary>83 /// <param name="options"></param>84 /// <returns>Task</returns>85 public Task DownAsync(ClickOptions options = null)86 {87 options = options ?? new ClickOptions();88 _button = options.Button;...

Full Screen

Full Screen

pay.cshtml.cs

Source:pay.cshtml.cs Github

copy

Full Screen

...52 var rect = await slideBtn.BoundingBoxAsync();53 var left = rect.X + 10;54 var top = rect.Y + 10;55 var mouse = page.Mouse;56 await mouse.MoveAsync(left, top);57 await page.Touchscreen.TapAsync(left, top);58 await mouse.DownAsync();59 var startTime = DateTime.Now;60 await mouse.MoveAsync(left + 800, top, new PuppeteerSharp.Input.MoveOptions { Steps = 30 });61 await page.Touchscreen.TapAsync(left + 800, top);62 Console.WriteLine(DateTime.Now - startTime);63 await mouse.UpAsync();64 }65 var channel = await page.WaitForSelectorAsync("[channelcode='alipaywap']");66 await channel.ClickAsync();67 var submit = await page.WaitForSelectorAsync("body > div.mask.confirmPay > section > div.btnPd > button");68 await submit.ClickAsync();69 }70 }71}...

Full Screen

Full Screen

MoveAsync

Using AI Code Generation

copy

Full Screen

1using System;2using System.Threading.Tasks;3using PuppeteerSharp;4{5 {6 static async Task Main(string[] args)7 {8 await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);9 using (var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = false }))10 {11 var page = await browser.NewPageAsync();12 await page.Mouse.MoveAsync(300, 300, new MouseMoveOptions { Steps = 10 });13 }14 }15 }16}

Full Screen

Full Screen

MoveAsync

Using AI Code Generation

copy

Full Screen

1var browser = await Puppeteer.LaunchAsync(new LaunchOptions2{3});4var page = await browser.NewPageAsync();5await page.Mouse.MoveAsync(100, 100);6await page.Mouse.ClickAsync();7await page.TypeAsync("PuppeteerSharp");8await page.Keyboard.PressAsync("Enter");9await page.WaitForNavigationAsync();10await browser.CloseAsync();11var browser = await Puppeteer.LaunchAsync(new LaunchOptions12{13});14var page = await browser.NewPageAsync();15await page.Mouse.MoveAsync(100, 100);16await page.Mouse.ClickAsync();17await page.TypeAsync("PuppeteerSharp");18await page.Keyboard.PressAsync("Enter");19await page.WaitForNavigationAsync();20await browser.CloseAsync();21var browser = await Puppeteer.LaunchAsync(new LaunchOptions22{23});24var page = await browser.NewPageAsync();25await page.Mouse.MoveAsync(100, 100);26await page.Mouse.ClickAsync();27await page.TypeAsync("PuppeteerSharp");28await page.Keyboard.PressAsync("Enter");29await page.WaitForNavigationAsync();30await browser.CloseAsync();31var browser = await Puppeteer.LaunchAsync(new LaunchOptions32{33});34var page = await browser.NewPageAsync();35await page.Mouse.MoveAsync(100, 100);36await page.Mouse.ClickAsync();37await page.TypeAsync("PuppeteerSharp");38await page.Keyboard.PressAsync("Enter");39await page.WaitForNavigationAsync();40await browser.CloseAsync();41var browser = await Puppeteer.LaunchAsync(new LaunchOptions42{

Full Screen

Full Screen

MoveAsync

Using AI Code Generation

copy

Full Screen

1await page.Mouse.MoveAsync(100, 200);2await page.Mouse.MoveAsync(200, 300);3await page.Mouse.ClickAsync(100, 200);4await page.Mouse.DownAsync();5await page.Mouse.UpAsync();6await page.Mouse.DblClickAsync(100, 200);7await page.Mouse.WheelAsync(100, 200);8await page.Mouse.DragAndDropAsync(100, 200, 300, 400);9await page.Mouse.Dispose();10await page.Mouse.DisposeAsync();11await page.Mouse.Dispose();12await page.Mouse.DisposeAsync();13await page.Mouse.Dispose();14await page.Mouse.DisposeAsync();15await page.Mouse.Dispose();16await page.Mouse.DisposeAsync();17await page.Mouse.Dispose();18await page.Mouse.DisposeAsync();19await page.Mouse.Dispose();20await page.Mouse.DisposeAsync();21await page.Mouse.Dispose();22await page.Mouse.DisposeAsync();23await page.Mouse.Dispose();

Full Screen

Full Screen

MoveAsync

Using AI Code Generation

copy

Full Screen

1var page = await browser.NewPageAsync();2await page.Mouse.MoveAsync(10, 10);3await page.Mouse.ClickAsync(10, 10);4var page = await browser.NewPageAsync();5await page.Mouse.ClickAsync(10, 10);6var page = await browser.NewPageAsync();7await page.Mouse.ClickAsync(10, 10);8var page = await browser.NewPageAsync();9await page.Mouse.ClickAsync(10, 10);10var page = await browser.NewPageAsync();11await page.Mouse.ClickAsync(10, 10);12var page = await browser.NewPageAsync();13await page.Mouse.ClickAsync(10, 10);14var page = await browser.NewPageAsync();15await page.Mouse.ClickAsync(10, 10);16var page = await browser.NewPageAsync();17await page.Mouse.ClickAsync(10, 10);18var page = await browser.NewPageAsync();19await page.Mouse.ClickAsync(10, 10);

Full Screen

Full Screen

MoveAsync

Using AI Code Generation

copy

Full Screen

1using PuppeteerSharp;2using System;3using System.Threading.Tasks;4{5 {6 static async Task Main(string[] args)7 {8 var options = new LaunchOptions { Headless = false };9 var browser = await Puppeteer.LaunchAsync(options);10 var page = await browser.NewPageAsync();11 await page.Mouse.MoveAsync(100, 100);12 await page.ScreenshotAsync("screenshot.png");13 await browser.CloseAsync();14 }15 }16}17using PuppeteerSharp;18using System;19using System.Threading.Tasks;20{21 {22 static async Task Main(string[] args)23 {24 var options = new LaunchOptions { Headless = false };25 var browser = await Puppeteer.LaunchAsync(options);26 var page = await browser.NewPageAsync();27 await page.Mouse.ClickAsync(100, 100);28 await page.ScreenshotAsync("screenshot.png");29 await browser.CloseAsync();30 }31 }32}33using PuppeteerSharp;34using System;35using System.Threading.Tasks;36{37 {38 static async Task Main(string[] args)39 {40 var options = new LaunchOptions { Headless = false };41 var browser = await Puppeteer.LaunchAsync(options);42 var page = await browser.NewPageAsync();43 await page.Mouse.DownAsync();44 await page.ScreenshotAsync("screenshot.png");45 await browser.CloseAsync();46 }47 }48}49using PuppeteerSharp;50using System;

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 Puppeteer-sharp 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