GithubHelp home page GithubHelp logo

permillisecond / nselene Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yashaka/nselene

0.0 2.0 0.0 170 KB

Consise API to Selenium for .Net (the port of Selene in python / Selenide in Java)

License: MIT License

C# 99.89% HTML 0.11%

nselene's Introduction

NSelene - Selenide "from scratch port" to .NET (C#, etc.)

A Tool created specifically for Web UI Test Automation in .NET world

So, Here it is... A more or less stabilized version, published to nuget gallery https://www.nuget.org/packages/NSelene

The version was covered with integration tests. The coverage was not complete in context of all probable use cases, but the "integration aspect" makes it good enough.

You can use tests as docs ;)

There is also an example tests project: https://github.com/yashaka/NSelene/blob/master/NSeleneExamples

Below you can find a short overview:

NSelene has no fully automatic driver management, you have to set it up manually, e.g. like here:

        [SetUp]
        public void InitDriver()
        {
            SetWebDriver(new FirefoxDriver());
        }

        [TearDown]
        public void TeardownDriver()
        {
            GetWebDriver().Quit();
        }

(https://github.com/yashaka/NSelene/blob/master/NSeleneExamples/BaseTest.cs)

Tests may look like this, via PageObject implemented in a "Modular/Procedural way":

        [TestFixture]
        public class TodoMvcTests : BaseTest
        {
            [Test]
            public void FilterTasks()
            {
                Tasks.Visit();

                Tasks.Add("a", "b", "c");
                Tasks.ShouldBe("a", "b", "c");

                Tasks.Toggle("b"); 

                Tasks.FilterActive();
                Tasks.ShouldBe("a", "c");

                Tasks.FilterCompleted();
                Tasks.ShouldBe("b");
            }
        }

(https://github.com/yashaka/NSelene/blob/master/NSeleneExamples/TodoMVC/WithPages/TodoMvcTests.cs)

where "procedural PageObject" aka "PageModule" may look like this:

        public static class Tasks
        {
            public static SeleneCollection List = SS("#todo-list>li"); 

            public static void Visit()
            {
                GoToUrl("https://todomvc4tasj.herokuapp.com/");
            }

            public static void FilterActive()
            {
                S(By.LinkText("Active")).Click();
            }

            public static void FilterCompleted()
            {
                S(By.LinkText("Completed")).Click();
            }

            public static void Add(params string[] taskTexts)
            {
                foreach (var text in taskTexts) 
                {
                    S("#new-todo").SetValue(text).PressEnter();
                }
            }

            public static void Toggle(string taskText)
            {
                List.FindBy(Have.ExactText(taskText)).S(".toggle").Click();
            }

            public static void ShouldBe(params string[] names)
            {
                List.FilterBy(Be.Visible).Should(Have.Texts(names));
            }
        }

See more examples of other styles, e.g. object oriented PageObjects, examples of how NSelene can be integrated into your current selenium based framework (to make it more stable and efficient) in NSeleneExamples project.

So... The main things are ported:

  • Selenide.$
  • SelenideElement#should
  • SelenideElement#shouldNot
  • SelenideElement#find / SelenideElement#$
  • SelenideElement#findAll / SelenideElement#$$
  • Selenide.$$
  • EllementsCollection#should
  • EllementsCollection#shouldNot
  • EllementsCollection#findBy
  • EllementsCollection#filterBy
  • EllementsCollection#get
  • all main Conditions
  • all main CollectionConditions

Though NSelene is not a "complete" port (no automatic screenshots, no automatic driver creation, etc.), even now It has some useful additions to the basic "selenide set" of features. The following a some features that are still absent in Selenide:

  • NSelene has better error messages for some complex queries like SS("#list-item").FindBy(Have.CssClass("specific")).Find(".inner-element").click()
  • NSelene can be much easyly integrated into existing selenium based frameworks, because it is object-oriented by its nature. It provides a Consice API to Selenium via both "OOP" (SeleneDriver class) and "static utils" wrappers (Selene static class) over WebDriver, not only "static utils wrappers" as in Selenide (Selenide utility class with static methods).
  • Because of the latter, NSelene also supports creation of "more than one driver per test". It can be rarely useful, but sometimes it "saves the life" on projects where "everything is too bad" :)

Feel free to share your thoughts and file an issue on github if you need something.

nselene's People

Contributors

yashaka avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.