Skip to content

Commit

Permalink
fix: fixed a number of failing bindings (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewingjm authored Oct 20, 2020
1 parent dc8a5eb commit 693ac9d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bindings/src/Capgemini.PowerApps.SpecFlowBindings/TestDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ public TestDriver(IJavaScriptExecutor javascriptExecutor)
/// <inheritdoc cref="ITestDriver"/>
public void LoadTestData(string data)
{
this.ExecuteAsyncScriptWithExceptionOnReject($"loadTestData(`{data}`)");
this.ExecuteDriverFunctionAsync($"loadTestData(`{data}`)");
}

/// <inheritdoc cref="ITestDriver"/>
public void DeleteTestData()
{
this.ExecuteAsyncScriptWithExceptionOnReject("deleteTestData()");
this.ExecuteDriverFunctionAsync("deleteTestData()");
}

/// <inheritdoc cref="ITestDriver"/>
public void OpenTestRecord(string recordAlias)
{
this.ExecuteAsyncScriptWithExceptionOnReject($"openTestRecord('{recordAlias}')");
this.ExecuteDriverFunctionAsync($"openTestRecord('{recordAlias}')");
}

/// <inheritdoc/>
public EntityReference GetTestRecordReference(string recordAlias)
{
var obj = (Dictionary<string, object>)this.javascriptExecutor.ExecuteScript($"{TestDriverReference}.getRecordReference('{recordAlias}');");
var obj = (Dictionary<string, object>)this.ExecuteDriverFunction($"getRecordReference('{recordAlias}')");

return new EntityReference((string)obj["entityType"], Guid.Parse((string)obj["id"]));
}
Expand All @@ -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));

Expand Down

0 comments on commit 693ac9d

Please sign in to comment.