Applitools + Specflow+ Selenium + C#

274 Views Asked by At

I'm asking for help, I'm already desperate.

I made a simple test script with Gherkin and generated the steps. I want to integrate Applitools into this process, that is, to use eyes.Check() method. But no matter how hard I try, every time I initialize the eyes object, I get the following error: Method not found: "Applitools.BatchInfo Applitools.IEyesBase.get_Batch().

Examples on applitools.com don't fit me, because the same Ruby implementation doesn't work for me, and the C# example doesn't involve using Gherkin.

My scenario:

@Default.Target.Environment:Edu
Feature: LoginScenario

@INWK.LP.C0002
Scenario: L001_Login
When I open Web Site
    And I login as user [email protected] with pass 12345678
Then I close browser

My steps:

using System.Drawing;
using Applitools;
using Applitools.Selenium;
using Lms.Helpers;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using TechTalk.SpecFlow;
using NUnit.Framework;
using Configuration = Applitools.Selenium.Configuration;

namespace Lms.Steps
{
    [TestFixture]
    [Binding]
    public class LoginInLmsSteps
    {
        private IWebDriver driver;
        private LoginHelper loginHelper;
        private Eyes eyes;
        private EyesRunner runner;

        private string Url => "https://lms.hse.ru/";

        [Before]
        [SetUp]
        public void BeforeEach()
        {
            Configuration config = new Configuration();
            config.SetApiKey("my_key");
            config.SetBatch(new BatchInfo("LMS Batch"));
            config.AddBrowser(800, 600, BrowserType.CHROME);

            runner = new ClassicRunner();

            eyes = new Eyes(runner);

            eyes.SetConfiguration(config);
        }

        [When(@"I open Web Site")]
        public void WhenIOpenWebSite()
        {
            driver = new ChromeDriver();
            driver.Url = Url;
        }
        
        [When(@"I login as user (.*) with pass (.*)")]
        public void WhenILoginAsUserWithPass(string username, string password)
        {
            eyes.Open(driver, "LMS", "Login test", new Size(800, 600));
            eyes.CheckWindow("Login Page");

            loginHelper.Login(username, password);

            eyes.CloseAsync();
        }
        
        [Then(@"I close browser")]
        public void ThenICloseBrowser()
        {
            driver.Quit();
            driver = null;
        }

        [TearDown]
        public void AfterEach()
        {
            // If the test was aborted before eyes.close was called, ends the test as aborted.
            eyes.AbortIfNotClosed();

            //Wait and collect all test results
            TestResultsSummary allTestResults = runner.GetAllTestResults();
        }
    }
}

That is, I catch the error already at the setup stage

I would be grateful for any help!

0

There are 0 best solutions below