-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathPauseFunction.cs
More file actions
50 lines (43 loc) · 1.63 KB
/
PauseFunction.cs
File metadata and controls
50 lines (43 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
using Microsoft.Extensions.Logging;
using Microsoft.PowerApps.TestEngine.Config;
using Microsoft.PowerApps.TestEngine.TestInfra;
using Microsoft.PowerFx;
using Microsoft.PowerFx.Core.Utils;
using Microsoft.PowerFx.Types;
namespace testengine.module
{
/// <summary>
/// This will pause the current test and allow the user to interact with the browser and inspect state when headless mode is false
/// </summary>
public class PauseFunction : ReflectionFunction
{
private readonly ITestInfraFunctions _testInfraFunctions;
private readonly ITestState _testState;
private readonly ILogger _logger;
public PauseFunction(ITestInfraFunctions testInfraFunctions, ITestState testState, ILogger logger)
: base("Pause", FormulaType.Blank)
{
_testInfraFunctions = testInfraFunctions;
_testState = testState;
_logger = logger;
}
public BlankValue Execute()
{
_logger.LogInformation("------------------------------\n\n" +
"Executing Pause function.");
if (!_testState.GetTestSettings().Headless)
{
var page = _testInfraFunctions.GetContext().Pages.First();
page.PauseAsync().Wait();
_logger.LogInformation("Successfully finished executing Pause function.");
}
else
{
_logger.LogInformation("Skip Pause function as in headless mode.");
}
return FormulaValue.NewBlank();
}
}
}