我在Stackoverflow中看到了答案,但这些答案与我正在使用的是Appium c#对BrowserStack的解决方案没有任何关系。我问过Browserstack,但他们说他们不能帮我解决代码问题。
IWebElement Success = _IOSdriver.FindElementByXPath("//XCUIElementTypeAlert[@name='Success']");
string ExpText = "Success";
string ActText = Success.Text;
if (ExpText.Equals(ActText))
{
Assert.AreEqual(ExpText, ActText);
Console.WriteLine("Message verified Successfully");
((IJavaScriptExecutor)_IOSdriver).ExecuteScript("browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"Passed", "reason": " Success not matched "}}");
_IOSdriver.ExecuteScript("String");
}
else
{
Console.WriteLine("Message Verification Failed");
((IJavaScriptExecutor)_IOSdriver).ExecuteScript("browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"failed", "reason": " Success not matched "}}");
}
嘿,你可以参考链接:https://www.browserstack.com/docs/app-automate/appium/set-up-tests/mark-tests-as-pass-fail#c_sharp
并执行样例测试,如果工作在你的框架中相应地改变。