Google analytics and yandex metrika events
To get GA and YM events, use special methods.
await tester.AssertNetworkEventsAsync(true, new string[] {
"ec=ga_category", "ea=ga_action", "el=ga_label", "yandex_event"
});
await Helper.ClearBrowserNetworkLogs(tester); // clearing events
Another way to intercept the YM event is to use it ?_ym_debug=1 in the address and browser event handling.
|
File: ExampleTest7.cs |
|
using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using System.Threading; using System.Threading.Tasks; using System.IO; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Reflection; using Newtonsoft.Json; using HatFramework; namespace Hat { public class ExampleTest5 { Tester tester; // The main variable for the autotest operation List<string> events; // The variable into which all browser events are collected // The main input function (the autotest starts with this function) public async void Main(Form browserWindow) { tester = new Tester(browserWindow); // Initializing the main variable await setUp(); // The function of getting started with the autotest await test(); // The function of performing test actions await tearDown(); // Autotest shutdown function } // A function that listens to browser events private void browserConsoleEvents(object sender, Microsoft.Web.WebView2.Core.CoreWebView2DevToolsProtocolEventReceivedEventArgs e) public async Task setUp() { await tester.BrowserFullScreenAsync(); // Sets the browser resolution to full screen /* * Let's turn on listening for browser events tester.BrowserView.CoreWebView2.GetDevToolsProtocolEventReceiver("Log.entryAdded").DevToolsProtocolEventReceived += browserConsoleEvents; } public async Task test() { await tester.TestBeginAsync(); // The beginning of the execution of actions await tester.GoToUrlAsync("https://test.site.com/?_ym_debug=1", 5); // Loading a page with YM event debugging enabled await tester.SetValueInElementAsync(Tester.BY_XPATH, "//input[@id='SECOND_NAME']", Helper.TestName); // Checking the YM event in the browser event list await tester.TestEndAsync(); // Completing actions } public async Task tearDown() { await tester.BrowserCloseAsync(); // Closes the browser } } } |
Thus, the autotest listens to all browser events and, after performing the actions, looks through all events in search of new ones
If the YM event is found, the test is considered successful.
Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation