Search code examples
c#appiumbrowserstack

How do i figure out what to use for my If statement. When I want to identify I am using Browserstack


Browserstack uses this uri http:/hub-cloud.browserstack.com/wd/hub. While locally I use a http://xxx.xxx.xx.xxx:xxxx/wd/hub. I have tried putting those in and I get an error I have also tried to get a Boolean for FI using Browserstack(which is the Browserstack setup code) so I have the following below. What should be in the if (Location)

if (Location)
    {
        var foundElement = (_IOSdriver.FindElementsByXPath(elementXPath));
        Assert.IsNotNull(foundElement);
        // Browserstack Check;
    }
    else
    {
        IReadOnlyList<IOSElement> allTextViewElements =
            _IOSdriver.FindElementsByXPath(elementXPath);

        //Setting the status of test as 'passed' or 'failed' based on the condition if results are found for the search

        if ((allTextViewElements.Count > 0))
        {
            ((IJavaScriptExecutor)_IOSdriver).ExecuteScript("browserstack_executor: {\"action\": \"setSessionStatus\", \"arguments\": {\"status\":\"passed\", \"reason\": \" Results found! \"}}");
        }
        else
        {
            ((IJavaScriptExecutor)_IOSdriver).ExecuteScript("browserstack_executor: {\"action\": \"setSessionStatus\", \"arguments\": {\"status\":\"failed\", \"reason\": \" Results not found!\"}}");
        }

Solution

  • The answer was to add

    var isbrowserstackrunning =false;
    if (isBrowserstackrunning !=true)
    {local stuff here including the capabilities you use locally}
    else
    {BrowserStack here including the capabilities you use for Browserstack.}