Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
themeRDark
using System;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using Reportium.client;
using Reportium.model;
using Reportium.test;
using Reportium.test.Result;

namespace PerfectoReportingSample
{
    public class Test
    {

        RemoteWebDriver driver;
        DesiredCapabilities capabilities;
        ReportiumClient reportiumClient;
        String errorMsg = null;

        [SetUp]
        public void initDriver()
        {
            capabilities = new DesiredCapabilities();
            capabilities.SetCapability("deviceName", "10101010");
            capabilities.SetCapability("securityToken", "token");
            driver = new RemoteWebDriver(new Uri("https://yourLab.perfectomobile.com/nexperience/perfectomobile/wd/hub"), capabilities, TimeSpan.FromSeconds(300));
            reportiumClient = CreateReportingClient(driver);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15);
        }

        [Test]
        public void openGooglePage()
        {
            try
            {
                reportiumClient.testStart("C# - Sample Test", new TestContextTags("C# Test"));
                Assert.IsNotNull(driver);
                driver.Navigate().GoToUrl("https://www.google.com/");
                driver.FindElementByXPath("//*[@name='q']");
            }
            catch (Exception ex)
            {
                errorMsg = ex.ToString();
            }
        }

        [TearDown]
        public void closeDriver()
        {
            if (errorMsg != null)
                reportiumClient.testStop(TestResultFactory.createFailure(errorMsg, null));
            else
            {
                reportiumClient.testStop(TestResultFactory.createSuccess());
            }
            driver.Close();
            driver.Quit();
        }

        private static ReportiumClient CreateReportingClient(RemoteWebDriver driver)
        {
            PerfectoExecutionContext perfectoExecutionContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
               .withProject(new Project("Perfecto Sample Project", "v1.0")) //optional
               .withContextTags(new[] { "Perfecto", "Sample", "C#" }) //optional
               .withJob(new Job("Sample C# Job", 1)) //optional
               .withWebDriver(driver)
               .build();
            return PerfectoClientFactory.createPerfectoReportiumClient(perfectoExecutionContext);
        }

        public static void Main() { }
    }
}
HTML
<iframe width="560" height="315" src="https://www.youtube.com/embed/hF_CHaffZyQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Content by Label
showLabelsfalse
max5
spacesTT
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ("csharp","reporting","nunit") and type = "page" and space = "TT"
labelsreporting nunit csharp

...