diff --git a/bindings/src/Capgemini.PowerApps.SpecFlowBindings/TestDriver.cs b/bindings/src/Capgemini.PowerApps.SpecFlowBindings/TestDriver.cs index f98d4ea..8aca3f6 100644 --- a/bindings/src/Capgemini.PowerApps.SpecFlowBindings/TestDriver.cs +++ b/bindings/src/Capgemini.PowerApps.SpecFlowBindings/TestDriver.cs @@ -38,25 +38,25 @@ public TestDriver(IJavaScriptExecutor javascriptExecutor) /// public void LoadTestData(string data) { - this.ExecuteAsyncScriptWithExceptionOnReject($"loadTestData(`{data}`)"); + this.ExecuteDriverFunctionAsync($"loadTestData(`{data}`)"); } /// public void DeleteTestData() { - this.ExecuteAsyncScriptWithExceptionOnReject("deleteTestData()"); + this.ExecuteDriverFunctionAsync("deleteTestData()"); } /// public void OpenTestRecord(string recordAlias) { - this.ExecuteAsyncScriptWithExceptionOnReject($"openTestRecord('{recordAlias}')"); + this.ExecuteDriverFunctionAsync($"openTestRecord('{recordAlias}')"); } /// public EntityReference GetTestRecordReference(string recordAlias) { - var obj = (Dictionary)this.javascriptExecutor.ExecuteScript($"{TestDriverReference}.getRecordReference('{recordAlias}');"); + var obj = (Dictionary)this.ExecuteDriverFunction($"getRecordReference('{recordAlias}')"); return new EntityReference((string)obj["entityType"], Guid.Parse((string)obj["id"])); } @@ -66,7 +66,12 @@ private static string GetExecuteScriptForAsyncFunction(string functionCall) return $"{TestDriverReference}.{functionCall}.then(arguments[arguments.length - 1]).catch(e => {{ arguments[arguments.length - 1](`{ErrorPrefix}: ${{ e.message }}`); }});"; } - private object ExecuteAsyncScriptWithExceptionOnReject(string functionCall) + private object ExecuteDriverFunction(string functionCall) + { + return this.javascriptExecutor.ExecuteScript($"return {TestDriverReference}.{functionCall};"); + } + + private object ExecuteDriverFunctionAsync(string functionCall) { var result = this.javascriptExecutor.ExecuteAsyncScript(GetExecuteScriptForAsyncFunction(functionCall));