How to use SkipBrowserFact method of PuppeteerSharp.Tests.Attributes.SkipBrowserFact class

Best Puppeteer-sharp code snippet using PuppeteerSharp.Tests.Attributes.SkipBrowserFact.SkipBrowserFact

CSSCoverageTests.cs

Source:CSSCoverageTests.cs Github

copy

Full Screen

...16 public CSSCoverageTests(ITestOutputHelper output) : base(output)17 {18 }19 [PuppeteerTest("coverage.spec.ts", "CSSCoverage", "should work")]20 [SkipBrowserFact(skipFirefox: true)]21 public async Task ShouldWork()22 {23 await Page.Coverage.StartCSSCoverageAsync();24 await Page.GoToAsync(TestConstants.ServerUrl + "/csscoverage/simple.html");25 var coverage = await Page.Coverage.StopCSSCoverageAsync();26 Assert.Single(coverage);27 Assert.Contains("/csscoverage/simple.html", coverage[0].Url);28 Assert.Equal(new CoverageEntryRange[]29 {30 new CoverageEntryRange31 {32 Start = 1,33 End = 2234 }35 }, coverage[0].Ranges);36 var range = coverage[0].Ranges[0];37 Assert.Equal("div { color: green; }", coverage[0].Text.Substring(range.Start, range.End - range.Start));38 }39 [PuppeteerTest("coverage.spec.ts", "CSSCoverage", "should report sourceURLs")]40 [SkipBrowserFact(skipFirefox: true)]41 public async Task ShouldReportSourceUrls()42 {43 await Page.Coverage.StartCSSCoverageAsync();44 await Page.GoToAsync(TestConstants.ServerUrl + "/csscoverage/sourceurl.html");45 var coverage = await Page.Coverage.StopCSSCoverageAsync();46 Assert.Single(coverage);47 Assert.Equal("nicename.css", coverage[0].Url);48 }49 [PuppeteerTest("coverage.spec.ts", "CSSCoverage", "should report multiple stylesheets")]50 [SkipBrowserFact(skipFirefox: true)]51 public async Task ShouldReportMultipleStylesheets()52 {53 await Page.Coverage.StartCSSCoverageAsync();54 await Page.GoToAsync(TestConstants.ServerUrl + "/csscoverage/multiple.html");55 var coverage = await Page.Coverage.StopCSSCoverageAsync();56 Assert.Equal(2, coverage.Length);57 var orderedList = coverage.OrderBy(c => c.Url);58 Assert.Contains("/csscoverage/stylesheet1.css", orderedList.ElementAt(0).Url);59 Assert.Contains("/csscoverage/stylesheet2.css", orderedList.ElementAt(1).Url);60 }61 [PuppeteerTest("coverage.spec.ts", "CSSCoverage", "should report stylesheets that have no coverage")]62 [SkipBrowserFact(skipFirefox: true)]63 public async Task ShouldReportStylesheetsThatHaveNoCoverage()64 {65 await Page.Coverage.StartCSSCoverageAsync();66 await Page.GoToAsync(TestConstants.ServerUrl + "/csscoverage/unused.html");67 var coverage = await Page.Coverage.StopCSSCoverageAsync();68 Assert.Single(coverage);69 var entry = coverage[0];70 Assert.Contains("unused.css", entry.Url);71 Assert.Empty(entry.Ranges);72 }73 [PuppeteerTest("coverage.spec.ts", "CSSCoverage", "should work with media queries")]74 [SkipBrowserFact(skipFirefox: true)]75 public async Task ShouldWorkWithMediaQueries()76 {77 await Page.Coverage.StartCSSCoverageAsync();78 await Page.GoToAsync(TestConstants.ServerUrl + "/csscoverage/media.html");79 var coverage = await Page.Coverage.StopCSSCoverageAsync();80 Assert.Single(coverage);81 var entry = coverage[0];82 Assert.Contains("/csscoverage/media.html", entry.Url);83 Assert.Equal(new CoverageEntryRange[]84 {85 new CoverageEntryRange86 {87 Start = 17,88 End = 3889 }90 }, coverage[0].Ranges);91 }92 [PuppeteerTest("coverage.spec.ts", "CSSCoverage", "should work with complicated usecases")]93 [SkipBrowserFact(skipFirefox: true)]94 public async Task ShouldWorkWithComplicatedUsecases()95 {96 const string involved = @"[97 {98 ""Url"": ""http://localhost:<PORT>/csscoverage/involved.html"",99 ""Ranges"": [100 {101 ""Start"": 149,102 ""End"": 297103 },104 {105 ""Start"": 327,106 ""End"": 433107 }108 ],109 ""Text"": ""\n @charset \""utf - 8\"";\n@namespace svg url(http://www.w3.org/2000/svg);\n@font-face {\n font-family: \""Example Font\"";\n src: url(\""./Dosis-Regular.ttf\"");\n}\n\n#fluffy {\n border: 1px solid black;\n z-index: 1;\n /* -webkit-disabled-property: rgb(1, 2, 3) */\n -lol-cats: \""dogs\"" /* non-existing property */\n}\n\n@media (min-width: 1px) {\n span {\n -webkit-border-radius: 10px;\n font-family: \""Example Font\"";\n animation: 1s identifier;\n }\n}\n""110 }111 ]";112 await Page.Coverage.StartCSSCoverageAsync();113 await Page.GoToAsync(TestConstants.ServerUrl + "/csscoverage/involved.html");114 var coverage = await Page.Coverage.StopCSSCoverageAsync();115 Assert.Equal(116 TestUtils.CompressText(involved),117 Regex.Replace(TestUtils.CompressText(JsonConvert.SerializeObject(coverage)), @":\d{4}\/", ":<PORT>/"));118 }119 [PuppeteerTest("coverage.spec.ts", "CSSCoverage", "should ignore injected stylesheets")]120 [SkipBrowserFact(skipFirefox: true)]121 public async Task ShouldIgnoreInjectedStylesheets()122 {123 await Page.Coverage.StartCSSCoverageAsync();124 await Page.AddStyleTagAsync(new AddTagOptions125 {126 Content = "body { margin: 10px;}"127 });128 // trigger style recalc129 var margin = await Page.EvaluateExpressionAsync<string>("window.getComputedStyle(document.body).margin");130 Assert.Equal("10px", margin);131 var coverage = await Page.Coverage.StopCSSCoverageAsync();132 Assert.Empty(coverage);133 }134 [PuppeteerTest("coverage.spec.ts", "CSSCoverage", "should work with a recently loaded stylesheet")]135 [SkipBrowserFact(skipFirefox: true)]136 public async Task ShouldWorkWithArRecentlyLoadedStylesheet()137 {138 await Page.Coverage.StartCSSCoverageAsync();139 await Page.EvaluateFunctionAsync(@"async url => {140 document.body.textContent = 'hello, world';141 const link = document.createElement('link');142 link.rel = 'stylesheet';143 link.href = url;144 document.head.appendChild(link);145 await new Promise(x => link.onload = x);146 }", TestConstants.ServerUrl + "/csscoverage/stylesheet1.css");147 var coverage = await Page.Coverage.StopCSSCoverageAsync();148 Assert.Single(coverage);149 }...

Full Screen

Full Screen

ExposeFunctionTests.cs

Source:ExposeFunctionTests.cs Github

copy

Full Screen

...13 public ExposeFunctionTests(ITestOutputHelper output) : base(output)14 {15 }16 [PuppeteerTest("page.spec.ts", "Page.exposeFunction", "should work")]17 [SkipBrowserFact(skipFirefox: true)]18 public async Task ShouldWork()19 {20 await Page.ExposeFunctionAsync("compute", (int a, int b) => a * b);21 var result = await Page.EvaluateExpressionAsync<int>("compute(9, 4)");22 Assert.Equal(36, result);23 }24 [PuppeteerTest("page.spec.ts", "Page.exposeFunction", "should throw exception in page context")]25 [SkipBrowserFact(skipFirefox: true)]26 public async Task ShouldThrowExceptionInPageContext()27 {28 await Page.ExposeFunctionAsync("woof", () => throw new Exception("WOOF WOOF"));29 var result = await Page.EvaluateFunctionAsync<JToken>(@" async () =>{30 try31 {32 await woof();33 }34 catch (e)35 {36 return { message: e.message, stack: e.stack};37 }38 }");39 Assert.Equal("WOOF WOOF", result.SelectToken("message").ToObject<string>());40 Assert.Contains("ExposeFunctionTests", result.SelectToken("stack").ToObject<string>());41 }42 [PuppeteerTest("page.spec.ts", "Page.exposeFunction", "should survive navigation")]43 [SkipBrowserFact(skipFirefox: true)]44 public async Task ShouldBeCallableFromInsideEvaluateOnNewDocument()45 {46 var called = false;47 await Page.ExposeFunctionAsync("woof", () => called = true);48 await Page.EvaluateFunctionOnNewDocumentAsync("() => woof()");49 await Page.ReloadAsync();50 Assert.True(called);51 }52 [PuppeteerTest("page.spec.ts", "Page.exposeFunction", "should work")]53 [SkipBrowserFact(skipFirefox: true)]54 public async Task ShouldSurviveNavigation()55 {56 await Page.ExposeFunctionAsync("compute", (int a, int b) => a * b);57 await Page.GoToAsync(TestConstants.EmptyPage);58 var result = await Page.EvaluateExpressionAsync<int>("compute(9, 4)");59 Assert.Equal(36, result);60 }61 [PuppeteerTest("page.spec.ts", "Page.exposeFunction", "should await returned promise")]62 [SkipBrowserFact(skipFirefox: true)]63 public async Task ShouldAwaitReturnedValueTask()64 {65 await Page.ExposeFunctionAsync("compute", (int a, int b) => Task.FromResult(a * b));66 var result = await Page.EvaluateExpressionAsync<int>("compute(3, 5)");67 Assert.Equal(15, result);68 }69 [PuppeteerTest("page.spec.ts", "Page.exposeFunction", "should work on frames")]70 [SkipBrowserFact(skipFirefox: true)]71 public async Task ShouldWorkOnFrames()72 {73 await Page.ExposeFunctionAsync("compute", (int a, int b) => Task.FromResult(a * b));74 await Page.GoToAsync(TestConstants.ServerUrl + "/frames/nested-frames.html");75 var frame = Page.FirstChildFrame();76 var result = await frame.EvaluateExpressionAsync<int>("compute(3, 5)");77 Assert.Equal(15, result);78 }79 [PuppeteerTest("page.spec.ts", "Page.exposeFunction", "should work on frames before navigation")]80 [SkipBrowserFact(skipFirefox: true)]81 public async Task ShouldWorkOnFramesBeforeNavigation()82 {83 await Page.GoToAsync(TestConstants.ServerUrl + "/frames/nested-frames.html");84 await Page.ExposeFunctionAsync("compute", (int a, int b) => Task.FromResult(a * b));85 var frame = Page.FirstChildFrame();86 var result = await frame.EvaluateExpressionAsync<int>("compute(3, 5)");87 Assert.Equal(15, result);88 }89 [PuppeteerTest("page.spec.ts", "Page.exposeFunction", "should work with complex objects")]90 [SkipBrowserFact(skipFirefox: true)]91 public async Task ShouldWorkWithComplexObjects()92 {93 await Page.GoToAsync(TestConstants.ServerUrl + "/frames/nested-frames.html");94 await Page.ExposeFunctionAsync("complexObject", (dynamic a, dynamic b) => Task.FromResult(new { X = a.x + b.x }));95 var result = await Page.EvaluateExpressionAsync<JToken>("complexObject({x: 5}, {x: 2})");96 Assert.Equal(7, result.SelectToken("x").ToObject<int>());97 }98 [SkipBrowserFact(skipFirefox: true)]99 public async Task ShouldAwaitReturnedTask()100 {101 var called = false;102 await Page.ExposeFunctionAsync("changeFlag", () =>103 {104 called = true;105 return Task.CompletedTask;106 });107 await Page.EvaluateExpressionAsync("changeFlag()");108 Assert.True(called);109 }110 [SkipBrowserFact(skipFirefox: true)]111 public async Task ShouldWorkWithAction()112 {113 var called = false;114 await Page.ExposeFunctionAsync("changeFlag", () =>115 {116 called = true;117 });118 await Page.EvaluateExpressionAsync("changeFlag()");119 Assert.True(called);120 }121 [SkipBrowserFact(skipFirefox: true)]122 public async Task ShouldKeepTheCallbackClean()123 {124 await Page.ExposeFunctionAsync("compute", (int a, int b) => a * b);125 await Page.EvaluateExpressionAsync<int>("compute(9, 4)");126 Assert.False(Page.Client.HasPendingCallbacks());127 }128 }129}...

Full Screen

Full Screen

RootOptionTests.cs

Source:RootOptionTests.cs Github

copy

Full Screen

...12 public RootOptionTests(ITestOutputHelper output) : base(output)13 {14 }15 [PuppeteerTest("accessibility.spec.ts", "root option", "should work a button")]16 [SkipBrowserFact(skipFirefox: true)]17 public async Task ShouldWorkAButton()18 {19 await Page.SetContentAsync("<button>My Button</button>");20 var button = await Page.QuerySelectorAsync("button");21 Assert.Equal(22 new SerializedAXNode23 {24 Role = "button",25 Name = "My Button"26 },27 await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions { Root = button }));28 }29 [PuppeteerTest("accessibility.spec.ts", "root option", "should work an input")]30 [SkipBrowserFact(skipFirefox: true)]31 public async Task ShouldWorkAnInput()32 {33 await Page.SetContentAsync("<input title='My Input' value='My Value'>");34 var input = await Page.QuerySelectorAsync("input");35 Assert.Equal(36 new SerializedAXNode37 {38 Role = "textbox",39 Name = "My Input",40 Value = "My Value"41 },42 await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions { Root = input }));43 }44 [PuppeteerTest("accessibility.spec.ts", "root option", "should work a menu")]45 [SkipBrowserFact(skipFirefox: true)]46 public async Task ShouldWorkAMenu()47 {48 await Page.SetContentAsync(@"49 <div role=""menu"" title=""My Menu"" >50 <div role=""menuitem"">First Item</div>51 <div role=""menuitem"">Second Item</div>52 <div role=""menuitem"">Third Item</div>53 </div>54 ");55 var menu = await Page.QuerySelectorAsync("div[role=\"menu\"]");56 var snapshot = await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions { Root = menu });57 var nodeToCheck = new SerializedAXNode58 {59 Role = "menu",60 Name = "My Menu",61 Orientation = "vertical",62 Children = new[]63 {64 new SerializedAXNode65 {66 Role = "menuitem",67 Name = "First Item"68 },69 new SerializedAXNode70 {71 Role = "menuitem",72 Name = "Second Item"73 },74 new SerializedAXNode75 {76 Role = "menuitem",77 Name = "Third Item"78 }79 }80 };81 Assert.Equal(nodeToCheck, snapshot);82 }83 [PuppeteerTest("accessibility.spec.ts", "root option", "should return null when the element is no longer in DOM")]84 [SkipBrowserFact(skipFirefox: true)]85 public async Task ShouldReturnNullWhenTheElementIsNoLongerInDOM()86 {87 await Page.SetContentAsync("<button>My Button</button>");88 var button = await Page.QuerySelectorAsync("button");89 await Page.EvaluateFunctionAsync("button => button.remove()", button);90 Assert.Null(await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions { Root = button }));91 }92 [PuppeteerTest("accessibility.spec.ts", "root option", "should support the interestingOnly option")]93 [SkipBrowserFact(skipFirefox: true)]94 public async Task ShouldSupportTheInterestingOnlyOption()95 {96 await Page.SetContentAsync("<div><button>My Button</button></div>");97 var div = await Page.QuerySelectorAsync("div");98 Assert.Null(await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions99 {100 Root = div101 }));102 Assert.Equal(103 new SerializedAXNode104 {105 Role = "generic",106 Name = "",107 Children = new[]...

Full Screen

Full Screen

TracingTests.cs

Source:TracingTests.cs Github

copy

Full Screen

...46 }47 }48 }49 [PuppeteerTest("tracing.spec.ts", "Tracing", "should output a trace")]50 [SkipBrowserFact(skipFirefox: true)]51 public async Task ShouldOutputATrace()52 {53 await Page.Tracing.StartAsync(new TracingOptions54 {55 Screenshots = true,56 Path = _file57 });58 await Page.GoToAsync(TestConstants.ServerUrl + "/grid.html");59 await Page.Tracing.StopAsync();60 Assert.True(File.Exists(_file));61 }62 [PuppeteerTest("tracing.spec.ts", "Tracing", "should run with custom categories if provided")]63 [SkipBrowserFact(skipFirefox: true)]64 public async Task ShouldRunWithCustomCategoriesProvided()65 {66 await Page.Tracing.StartAsync(new TracingOptions67 {68 Screenshots = true,69 Path = _file,70 Categories = new List<string>71 {72 "disabled-by-default-v8.cpu_profiler.hires"73 }74 });75 await Page.Tracing.StopAsync();76 using (var file = File.OpenText(_file))77 using (var reader = new JsonTextReader(file))78 {79 var traceJson = JToken.ReadFrom(reader);80 Assert.Contains("disabled-by-default-v8.cpu_profiler.hires", traceJson["metadata"]["trace-config"].ToString());81 }82 }83 [PuppeteerTest("tracing.spec.ts", "Tracing", "should throw if tracing on two pages")]84 [SkipBrowserFact(skipFirefox: true)]85 public async Task ShouldThrowIfTracingOnTwoPages()86 {87 await Page.Tracing.StartAsync(new TracingOptions88 {89 Path = _file90 });91 var newPage = await Browser.NewPageAsync();92 await Assert.ThrowsAsync<InvalidOperationException>(async () =>93 {94 await Page.Tracing.StartAsync(new TracingOptions95 {96 Path = _file97 });98 });99 await newPage.CloseAsync();100 await Page.Tracing.StopAsync();101 }102 [PuppeteerTest("tracing.spec.ts", "Tracing", "should return a buffer")]103 [SkipBrowserFact(skipFirefox: true)]104 public async Task ShouldReturnABuffer()105 {106 await Page.Tracing.StartAsync(new TracingOptions107 {108 Screenshots = true,109 Path = _file110 });111 await Page.GoToAsync(TestConstants.ServerUrl + "/grid.html");112 var trace = await Page.Tracing.StopAsync();113 var buf = File.ReadAllText(_file);114 Assert.Equal(trace, buf);115 }116 [PuppeteerTest("tracing.spec.ts", "Tracing", "should work without options")]117 [SkipBrowserFact(skipFirefox: true)]118 public async Task ShouldWorkWithoutOptions()119 {120 await Page.Tracing.StartAsync();121 await Page.GoToAsync(TestConstants.ServerUrl + "/grid.html");122 var trace = await Page.Tracing.StopAsync();123 Assert.NotNull(trace);124 }125 [PuppeteerTest("tracing.spec.ts", "Tracing", "should support a buffer without a path")]126 [SkipBrowserFact(skipFirefox: true)]127 public async Task ShouldSupportABufferWithoutAPath()128 {129 await Page.Tracing.StartAsync(new TracingOptions130 {131 Screenshots = true132 });133 await Page.GoToAsync(TestConstants.ServerUrl + "/grid.html");134 var trace = await Page.Tracing.StopAsync();135 Assert.Contains("screenshot", trace);136 }137 }138}...

Full Screen

Full Screen

PageWorkerTests.cs

Source:PageWorkerTests.cs Github

copy

Full Screen

...12 public PageWorkerTests(ITestOutputHelper output) : base(output)13 {14 }15 [PuppeteerTest("worker.spec.ts", "Workers", "Page.workers")]16 [SkipBrowserFact(skipFirefox: true)]17 public async Task PageWorkers()18 {19 var workerCreatedTcs = new TaskCompletionSource<bool>();20 var workerDestroyedTcs = new TaskCompletionSource<bool>();21 Page.WorkerCreated += (_, _) => workerCreatedTcs.TrySetResult(true);22 Page.WorkerDestroyed += (_, _) => workerDestroyedTcs.TrySetResult(true);23 await Task.WhenAll(24 workerCreatedTcs.Task,25 Page.GoToAsync(TestConstants.ServerUrl + "/worker/worker.html"));26 var worker = Page.Workers[0];27 Assert.Contains("worker.js", worker.Url);28 Assert.Equal("worker function result", await worker.EvaluateExpressionAsync<string>("self.workerFunction()"));29 await Page.GoToAsync(TestConstants.EmptyPage);30 await workerDestroyedTcs.Task.WithTimeout();31 Assert.Empty(Page.Workers);32 }33 [PuppeteerTest("worker.spec.ts", "Workers", "should emit created and destroyed events")]34 [SkipBrowserFact(skipFirefox: true)]35 public async Task ShouldEmitCreatedAndDestroyedEvents()36 {37 var workerCreatedTcs = new TaskCompletionSource<Worker>();38 Page.WorkerCreated += (_, e) => workerCreatedTcs.TrySetResult(e.Worker);39 var workerObj = await Page.EvaluateFunctionHandleAsync("() => new Worker('data:text/javascript,1')");40 var worker = await workerCreatedTcs.Task;41 var workerDestroyedTcs = new TaskCompletionSource<Worker>();42 Page.WorkerDestroyed += (_, e) => workerDestroyedTcs.TrySetResult(e.Worker);43 await Page.EvaluateFunctionAsync("workerObj => workerObj.terminate()", workerObj);44 Assert.Same(worker, await workerDestroyedTcs.Task);45 }46 [PuppeteerTest("worker.spec.ts", "Workers", "should report console logs")]47 [SkipBrowserFact(skipFirefox: true)]48 public async Task ShouldReportConsoleLogs()49 {50 var consoleTcs = new TaskCompletionSource<ConsoleMessage>();51 Page.Console += (_, e) => consoleTcs.TrySetResult(e.Message);52 await Page.EvaluateFunctionAsync("() => new Worker(`data:text/javascript,console.log(1)`)");53 var log = await consoleTcs.Task;54 Assert.Equal("1", log.Text);55 Assert.Equal(new ConsoleMessageLocation56 {57 URL = "",58 LineNumber = 0,59 ColumnNumber = 860 }, log.Location);61 }62 [PuppeteerTest("worker.spec.ts", "Workers", "should have JSHandles for console logs")]63 [SkipBrowserFact(skipFirefox: true)]64 public async Task ShouldHaveJSHandlesForConsoleLogs()65 {66 var consoleTcs = new TaskCompletionSource<ConsoleMessage>();67 Page.Console += (_, e) =>68 {69 consoleTcs.TrySetResult(e.Message);70 };71 await Page.EvaluateFunctionAsync("() => new Worker(`data:text/javascript,console.log(1, 2, 3, this)`)");72 var log = await consoleTcs.Task;73 Assert.Equal("1 2 3 JSHandle@object", log.Text);74 Assert.Equal(4, log.Args.Count);75 var json = await (await log.Args[3].GetPropertyAsync("origin")).JsonValueAsync<object>();76 Assert.Equal("null", json);77 }78 [PuppeteerTest("worker.spec.ts", "Workers", "should have an execution context")]79 [SkipBrowserFact(skipFirefox: true)]80 public async Task ShouldHaveAnExecutionContext()81 {82 var workerCreatedTcs = new TaskCompletionSource<Worker>();83 Page.WorkerCreated += (_, e) => workerCreatedTcs.TrySetResult(e.Worker);84 await Page.EvaluateFunctionAsync("() => new Worker(`data:text/javascript,console.log(1)`)");85 var worker = await workerCreatedTcs.Task;86 Assert.Equal(2, await worker.EvaluateExpressionAsync<int>("1+1"));87 }88 [PuppeteerTest("worker.spec.ts", "Workers", "should report errors")]89 [SkipBrowserFact(skipFirefox: true)]90 public async Task ShouldReportErrors()91 {92 var errorTcs = new TaskCompletionSource<string>();93 Page.PageError += (_, e) => errorTcs.TrySetResult(e.Message);94 await Page.EvaluateFunctionAsync("() => new Worker(`data:text/javascript, throw new Error('this is my error');`)");95 var errorLog = await errorTcs.Task;96 Assert.Contains("this is my error", errorLog);97 }98 }99}...

Full Screen

Full Screen

CreateCDPSessionTests.cs

Source:CreateCDPSessionTests.cs Github

copy

Full Screen

...15 public CreateCDPSessionTests(ITestOutputHelper output) : base(output)16 {17 }18 [PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should work")]19 [SkipBrowserFact(skipFirefox: true)]20 public async Task ShouldWork()21 {22 var client = await Page.Target.CreateCDPSessionAsync();23 await Task.WhenAll(24 client.SendAsync("Runtime.enable"),25 client.SendAsync("Runtime.evaluate", new RuntimeEvaluateRequest { Expression = "window.foo = 'bar'" })26 );27 var foo = await Page.EvaluateExpressionAsync<string>("window.foo");28 Assert.Equal("bar", foo);29 }30 [PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should send events")]31 [SkipBrowserFact(skipFirefox: true)]32 public async Task ShouldSendEvents()33 {34 var client = await Page.Target.CreateCDPSessionAsync();35 await client.SendAsync("Network.enable");36 var events = new List<object>();37 client.MessageReceived += (_, e) =>38 {39 if (e.MessageID == "Network.requestWillBeSent")40 {41 events.Add(e.MessageData);42 }43 };44 await Page.GoToAsync(TestConstants.EmptyPage);45 Assert.Single(events);46 }47 [PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should enable and disable domains independently")]48 [SkipBrowserFact(skipFirefox: true)]49 public async Task ShouldEnableAndDisableDomainsIndependently()50 {51 var client = await Page.Target.CreateCDPSessionAsync();52 await client.SendAsync("Runtime.enable");53 await client.SendAsync("Debugger.enable");54 // JS coverage enables and then disables Debugger domain.55 await Page.Coverage.StartJSCoverageAsync();56 await Page.Coverage.StopJSCoverageAsync();57 // generate a script in page and wait for the event.58 var eventTask = WaitEvent(client, "Debugger.scriptParsed");59 await Task.WhenAll(60 eventTask,61 Page.EvaluateExpressionAsync("//# sourceURL=foo.js")62 );63 // expect events to be dispatched.64 Assert.Equal("foo.js", eventTask.Result["url"].Value<string>());65 }66 [PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should be able to detach session")]67 [SkipBrowserFact(skipFirefox: true)]68 public async Task ShouldBeAbleToDetachSession()69 {70 var client = await Page.Target.CreateCDPSessionAsync();71 await client.SendAsync("Runtime.enable");72 var evalResponse = await client.SendAsync("Runtime.evaluate", new RuntimeEvaluateRequest73 {74 Expression = "1 + 2",75 ReturnByValue = true76 });77 Assert.Equal(3, evalResponse["result"]["value"].ToObject<int>());78 await client.DetachAsync();79 var exception = await Assert.ThrowsAnyAsync<Exception>(()80 => client.SendAsync("Runtime.evaluate", new RuntimeEvaluateRequest81 {82 Expression = "3 + 1",83 ReturnByValue = true84 }));85 Assert.Contains("Session closed.", exception.Message);86 }87 [PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should throw nice errors")]88 [SkipBrowserFact(skipFirefox: true)]89 public async Task ShouldThrowNiceErrors()90 {91 var client = await Page.Target.CreateCDPSessionAsync();92 async Task TheSourceOfTheProblems() => await client.SendAsync("ThisCommand.DoesNotExist");93 var exception = await Assert.ThrowsAsync<MessageException>(async () =>94 {95 await TheSourceOfTheProblems();96 });97 Assert.Contains("TheSourceOfTheProblems", exception.StackTrace);98 Assert.Contains("ThisCommand.DoesNotExist", exception.Message);99 }100 [PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should expose the underlying connection")]101 [SkipBrowserFact(skipFirefox: true)]102 public async Task ShouldExposeTheUnderlyingConnection()103 => Assert.NotNull(await Page.Target.CreateCDPSessionAsync());104 }105}...

Full Screen

Full Screen

PageWaitForFileChooserTests.cs

Source:PageWaitForFileChooserTests.cs Github

copy

Full Screen

...13 public PageWaitForFileChooserTests(ITestOutputHelper output) : base(output)14 {15 }16 [PuppeteerTest("input.spec.ts", "Page.waitForFileChooser", "should work when file input is attached to DOM")]17 [SkipBrowserFact(skipFirefox: true)]18 public async Task ShouldWorkWhenFileInputIsAttachedToDOM()19 {20 await Page.SetContentAsync("<input type=file>");21 var waitForTask = Page.WaitForFileChooserAsync();22 await Task.WhenAll(23 waitForTask,24 Page.ClickAsync("input"));25 Assert.NotNull(waitForTask.Result);26 }27 [PuppeteerTest("input.spec.ts", "Page.waitForFileChooser", "should work when file input is not attached to DOM")]28 [SkipBrowserFact(skipFirefox: true)]29 public async Task ShouldWorkWhenFileInputIsNotAttachedToDOM()30 {31 var waitForTask = Page.WaitForFileChooserAsync();32 await Task.WhenAll(33 waitForTask,34 Page.EvaluateFunctionAsync(@"() =>35 {36 const el = document.createElement('input');37 el.type = 'file';38 el.click();39 }"));40 Assert.NotNull(waitForTask.Result);41 }42 [PuppeteerTest("input.spec.ts", "Page.waitForFileChooser", "should respect timeout")]43 [SkipBrowserFact(skipFirefox: true)]44 public Task ShouldRespectTimeout()45 {46 return Assert.ThrowsAsync<TimeoutException>(() => Page.WaitForFileChooserAsync(new WaitForFileChooserOptions47 {48 Timeout = 149 }));50 }51 [PuppeteerTest("input.spec.ts", "Page.waitForFileChooser", "should respect default timeout when there is no custom timeout")]52 [SkipBrowserFact(skipFirefox: true)]53 public Task ShouldRespectTimeoutWhenThereIsNoCustomTimeout()54 {55 Page.DefaultTimeout = 1;56 return Assert.ThrowsAsync<TimeoutException>(() => Page.WaitForFileChooserAsync());57 }58 [PuppeteerTest("input.spec.ts", "Page.waitForFileChooser", "should prioritize exact timeout over default timeout")]59 [SkipBrowserFact(skipFirefox: true)]60 public Task ShouldPrioritizeExactTimeoutOverDefaultTimeout()61 {62 Page.DefaultTimeout = 0;63 return Assert.ThrowsAsync<TimeoutException>(() => Page.WaitForFileChooserAsync(new WaitForFileChooserOptions64 {65 Timeout = 166 }));67 }68 [PuppeteerTest("input.spec.ts", "Page.waitForFileChooser", "should work with no timeout")]69 [SkipBrowserFact(skipFirefox: true)]70 public async Task ShouldWorkWithNoTimeout()71 {72 var waitForTask = Page.WaitForFileChooserAsync(new WaitForFileChooserOptions { Timeout = 0 });73 await Task.WhenAll(74 waitForTask,75 Page.EvaluateFunctionAsync(@"() => setTimeout(() =>76 {77 const el = document.createElement('input');78 el.type = 'file';79 el.click();80 }, 50)"));81 Assert.NotNull(waitForTask.Result);82 }83 [PuppeteerTest("input.spec.ts", "Page.waitForFileChooser", "should return the same file chooser when there are many watchdogs simultaneously")]84 [SkipBrowserFact(skipFirefox: true)]85 public async Task ShouldReturnTheSameFileChooserWhenThereAreManyWatchdogsSimultaneously()86 {87 await Page.SetContentAsync("<input type=file>");88 var fileChooserTask1 = Page.WaitForFileChooserAsync();89 var fileChooserTask2 = Page.WaitForFileChooserAsync();90 await Task.WhenAll(91 fileChooserTask1,92 fileChooserTask2,93 Page.QuerySelectorAsync("input").EvaluateFunctionAsync("input => input.click()"));94 Assert.Same(fileChooserTask1.Result, fileChooserTask2.Result);95 }96 }97}...

Full Screen

Full Screen

FileChooserIsMultipleTests.cs

Source:FileChooserIsMultipleTests.cs Github

copy

Full Screen

...13 public FileChooserIsMultipleTests(ITestOutputHelper output) : base(output)14 {15 }16 [PuppeteerTest("input.spec.ts", "FileChooser.isMultiple", "should work for single file pick")]17 [SkipBrowserFact(skipFirefox: true)]18 public async Task ShouldWorkForSingleFilePick()19 {20 await Page.SetContentAsync("<input type=file>");21 var waitForTask = Page.WaitForFileChooserAsync();22 await Task.WhenAll(23 waitForTask,24 Page.ClickAsync("input"));25 Assert.False(waitForTask.Result.IsMultiple);26 }27 [PuppeteerTest("input.spec.ts", "FileChooser.isMultiple", "should work for \"multiple\"")]28 [SkipBrowserFact(skipFirefox: true)]29 public async Task ShouldWorkForMultiple()30 {31 await Page.SetContentAsync("<input type=file multiple>");32 var waitForTask = Page.WaitForFileChooserAsync();33 await Task.WhenAll(34 waitForTask,35 Page.ClickAsync("input"));36 Assert.True(waitForTask.Result.IsMultiple);37 }38 [PuppeteerTest("input.spec.ts", "FileChooser.isMultiple", "should work for \"webkitdirectory\"")]39 [SkipBrowserFact(skipFirefox: true)]40 public async Task ShouldWorkForWebkitDirectory()41 {42 await Page.SetContentAsync("<input type=file multiple webkitdirectory>");43 var waitForTask = Page.WaitForFileChooserAsync();44 await Task.WhenAll(45 waitForTask,46 Page.ClickAsync("input"));47 Assert.True(waitForTask.Result.IsMultiple);48 }49 }50}...

Full Screen

Full Screen

SkipBrowserFact

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Text;4using Xunit;5{6 {7 public SkipBrowserFact()8 {9 if (TestConstants.IsSkipBrowserFact)10 {11 Skip = "SkipBrowserFact";12 }13 }14 }15}16using System;17using System.Collections.Generic;18using System.Text;19using Xunit;20{21 {22 public SkipBrowserFact()23 {24 if (TestConstants.IsSkipBrowserFact)25 {26 Skip = "SkipBrowserFact";27 }28 }29 }30}31using System;32using System.Collections.Generic;33using System.Text;34using Xunit;35{36 {37 public SkipBrowserFact()38 {39 if (TestConstants.IsSkipBrowserFact)40 {41 Skip = "SkipBrowserFact";42 }43 }44 }45}46using System;47using System.Collections.Generic;48using System.Text;49using Xunit;50{51 {52 public SkipBrowserFact()53 {54 if (TestConstants.IsSkipBrowserFact)55 {56 Skip = "SkipBrowserFact";57 }58 }59 }60}61using System;62using System.Collections.Generic;63using System.Text;64using Xunit;65{66 {67 public SkipBrowserFact()68 {69 if (TestConstants.IsSkipBrowserFact)70 {71 Skip = "SkipBrowserFact";72 }73 }74 }75}76using System;77using System.Collections.Generic;78using System.Text;79using Xunit;

Full Screen

Full Screen

SkipBrowserFact

Using AI Code Generation

copy

Full Screen

1using Xunit;2using PuppeteerSharp.Tests.Attributes;3using System;4using System.Collections.Generic;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 public SkipBrowserFact()11 {12 if (TestConstants.IsTravis)13 {14 this.Skip = "Skipped on Travis";15 }16 }17 }18}19using Xunit;20using PuppeteerSharp.Tests.Attributes;21using System;22using System.Collections.Generic;23using System.Linq;24using System.Text;25using System.Threading.Tasks;26{27 {28 public SkipBrowserFact()29 {30 if (TestConstants.IsTravis)31 {32 this.Skip = "Skipped on Travis";33 }34 }35 }36}37using Xunit;38using PuppeteerSharp.Tests.Attributes;39using System;40using System.Collections.Generic;41using System.Linq;42using System.Text;43using System.Threading.Tasks;44{45 {46 public SkipBrowserFact()47 {48 if (TestConstants.IsTravis)49 {50 this.Skip = "Skipped on Travis";51 }52 }53 }54}55using Xunit;56using PuppeteerSharp.Tests.Attributes;57using System;58using System.Collections.Generic;59using System.Linq;60using System.Text;61using System.Threading.Tasks;62{63 {64 public SkipBrowserFact()65 {66 if (TestConstants.IsTravis)67 {68 this.Skip = "Skipped on Travis";69 }70 }71 }72}73using Xunit;74using PuppeteerSharp.Tests.Attributes;75using System;76using System.Collections.Generic;77using System.Linq;78using System.Text;79using System.Threading.Tasks;80{

Full Screen

Full Screen

SkipBrowserFact

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using Xunit;7using PuppeteerSharp.Tests.Attributes;8{9 {10 [SkipBrowserFact(skipFirefox: true)]11 public async Task SkipBrowserFactTest1()12 {13 var browser = await Puppeteer.LaunchAsync(new LaunchOptions14 {15 ExecutablePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"16 });17 var page = await browser.NewPageAsync();18 await page.ScreenshotAsync("C:/Users/username/Desktop/test.png");19 await browser.CloseAsync();20 }21 }22}23using System;24using System.Collections.Generic;25using System.Linq;26using System.Text;27using System.Threading.Tasks;28using Xunit;29using PuppeteerSharp.Tests.Attributes;30{31 {32 [SkipBrowserFact(skipFirefox: true)]33 public async Task SkipBrowserFactTest1()34 {35 var browser = await Puppeteer.LaunchAsync(new LaunchOptions36 {37 });38 var page = await browser.NewPageAsync();39 await page.ScreenshotAsync("C:/Users/username/Desktop/test.png");40 await browser.CloseAsync();41 }42 }43}44using System;45using System.Collections.Generic;46using System.Linq;47using System.Text;48using System.Threading.Tasks;49using Xunit;50using PuppeteerSharp.Tests.Attributes;51{52 {53 [SkipBrowserFact(skipFirefox: false)]54 public async Task SkipBrowserFactTest1()55 {56 var browser = await Puppeteer.LaunchAsync(new LaunchOptions57 {58 });

Full Screen

Full Screen

SkipBrowserFact

Using AI Code Generation

copy

Full Screen

1using PuppeteerSharp.Tests.Attributes;2using Xunit;3{4 {5 [SkipBrowserFact(skipFirefox: true)]6 public void SkipBrowserFactTestMethod()7 {8 Assert.True(true);9 }10 }11}12using PuppeteerSharp.Tests.Attributes;13using Xunit;14{15 {16 [SkipBrowserFact(skipFirefox: false)]17 public void SkipBrowserFactTestMethod()18 {19 Assert.True(true);20 }21 }22}23using PuppeteerSharp.Tests.Attributes;24using Xunit;25{26 {27 [SkipBrowserFact(skipFirefox: true)]28 public void SkipBrowserFactTestMethod()29 {30 Assert.True(false);31 }32 }33}34using PuppeteerSharp.Tests.Attributes;35using Xunit;36{37 {38 [SkipBrowserFact(skipFirefox: false)]39 public void SkipBrowserFactTestMethod()40 {41 Assert.True(false);42 }43 }44}45using PuppeteerSharp.Tests.Attributes;46using Xunit;47{48 {49 [SkipBrowserFact(skipFirefox: true)]50 public void SkipBrowserFactTestMethod()51 {52 Assert.True(true);53 }54 }55}56using PuppeteerSharp.Tests.Attributes;57using Xunit;58{59 {60 [SkipBrowserFact(skipFirefox: false)]61 public void SkipBrowserFactTestMethod()62 {63 Assert.True(true);64 }65 }66}

Full Screen

Full Screen

SkipBrowserFact

Using AI Code Generation

copy

Full Screen

1using PuppeteerSharp.Tests.Attributes;2using Xunit;3{4 {5 [SkipBrowserFact(skipFirefox: true, skipWebkit: true)]6 public void TestSkipBrowserFact()7 {8 }9 }10}11using PuppeteerSharp.Tests.Attributes;12using Xunit;13{14 {15 [SkipBrowserFact(skipFirefox: true, skipWebkit: true)]16 public void TestSkipBrowserFact()17 {18 }19 }20}21using PuppeteerSharp.Tests.Attributes;22using Xunit;23{24 {25 [SkipBrowserFact(skipFirefox: true, skipWebkit: true)]26 public void TestSkipBrowserFact()27 {28 }29 }30}31using PuppeteerSharp.Tests.Attributes;32using Xunit;33{34 {35 [SkipBrowserFact(skipFirefox: true, skipWebkit: true)]36 public void TestSkipBrowserFact()37 {38 }39 }40}41using PuppeteerSharp.Tests.Attributes;42using Xunit;43{44 {45 [SkipBrowserFact(skipFirefox: true, skipWebkit: true)]46 public void TestSkipBrowserFact()47 {48 }49 }50}51using PuppeteerSharp.Tests.Attributes;52using Xunit;53{54 {55 [SkipBrowserFact(skipFirefox: true, skipWebkit: true)]56 public void TestSkipBrowserFact()57 {58 }59 }60}

Full Screen

Full Screen

SkipBrowserFact

Using AI Code Generation

copy

Full Screen

1using PuppeteerSharp.Tests.Attributes;2using Xunit;3{4 {5 [SkipBrowserFact(skipFirefox: true)]6 public async Task Test1()7 {8 }9 }10}11Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'SkipBrowserFact' could not be found (are you missing a using directive or an assembly reference?) PuppeteerSharp.Tests C:\Users\user\source\repos\PuppeteerSharp.Tests\PuppeteerSharp.Tests\1.cs 4 Active12PuppeteerSharp.Tests (netcoreapp2.1)13PuppeteerSharp.Tests (netcoreapp2.1)14PuppeteerSharp.Tests (netcoreapp2.1)15PuppeteerSharp.Tests (netcoreapp2.1)16PuppeteerSharp.Tests (netcoreapp2.1)17PuppeteerSharp.Tests (netcoreapp2.1)18PuppeteerSharp.Tests (netcoreapp2.1)19PuppeteerSharp.Tests (netcoreapp2.1)20PuppeteerSharp.Tests (netcoreapp2.1)

Full Screen

Full Screen

SkipBrowserFact

Using AI Code Generation

copy

Full Screen

1using PuppeteerSharp.Tests.Attributes;2using Xunit;3{4 [Collection(TestConstants.TestFixtureCollectionName)]5 {6 [SkipBrowserFact(skipHeadless: true)]7 public async Task Test1()8 {9 await Page.GoToAsync(TestConstants.EmptyPage);10 Assert.True(true);11 }12 }13}14using PuppeteerSharp.Tests.Attributes;15using Xunit;16{17 [Collection(TestConstants.TestFixtureCollectionName)]18 {19 [SkipBrowserFact(skipHeadless: false)]20 public async Task Test1()21 {22 await Page.GoToAsync(TestConstants.EmptyPage);23 Assert.True(true);24 }25 }26}27using PuppeteerSharp.Tests.Attributes;28using Xunit;29{30 [Collection(TestConstants.TestFixtureCollectionName)]31 {32 [SkipBrowserFact(skipHeadless: false)]33 public async Task Test1()34 {35 await Page.GoToAsync(TestConstants.EmptyPage);36 Assert.True(true);37 }38 }39}40using PuppeteerSharp.Tests.Attributes;41using Xunit;42{43 [Collection(TestConstants.TestFixtureCollectionName)]44 {45 [SkipBrowserFact(skipHeadless: false)]46 public async Task Test1()47 {48 await Page.GoToAsync(TestConstants.EmptyPage);49 Assert.True(true);50 }51 }52}

Full Screen

Full Screen

SkipBrowserFact

Using AI Code Generation

copy

Full Screen

1[SkipBrowserFact(SkipBrowserFactAttribute.SkipBrowserFactAttributeTarget.Firefox)]2public async Task ShouldWork()3{4}5[SkipBrowserFact(SkipBrowserFactAttribute.SkipBrowserFactAttributeTarget.Firefox)]6public async Task ShouldWork()7{8}9[SkipBrowserFact(SkipBrowserFactAttribute.SkipBrowserFactAttributeTarget.Firefox)]10public async Task ShouldWork()11{12}13[SkipBrowserFact(SkipBrowserFactAttribute.SkipBrowserFactAttributeTarget.Firefox)]14public async Task ShouldWork()15{16}17[SkipBrowserFact(SkipBrowserFactAttribute.SkipBrowserFactAttributeTarget.Firefox)]18public async Task ShouldWork()19{20}21[SkipBrowserFact(SkipBrowserFactAttribute.SkipBrowserFactAttributeTarget.Firefox)]22public async Task ShouldWork()23{24}25[SkipBrowserFact(SkipBrowserFactAttribute.SkipBrowserFactAttributeTarget.Firefox)]26public async Task ShouldWork()27{28}29[SkipBrowserFact(SkipBrowserFactAttribute.SkipBrowserFactAttributeTarget.Firefox)]30public async Task ShouldWork()31{32}33[SkipBrowserFact(SkipBrowserFactAttribute.SkipBrowserFactAttributeTarget.Firefox)]34public async Task ShouldWork()35{36}

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.

Most used method in SkipBrowserFact

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful