public void FindElement_ShouldThrowExceptionIfNoElementsFound()
        {
            var by1Mock = new Mock <OpenQA.Selenium.By>();

            by1Mock.Setup(by => by.FindElements(It.IsAny <ISearchContext>())).Returns(() => new ReadOnlyCollection <IWebElement>(new List <IWebElement>()));

            var by2Mock = new Mock <OpenQA.Selenium.By>();

            by2Mock.Setup(by => by.FindElements(It.IsAny <ISearchContext>())).Returns(() => new ReadOnlyCollection <IWebElement>(new List <IWebElement>()));

            var by3Mock = new Mock <OpenQA.Selenium.By>();

            by3Mock.Setup(by => by.FindElements(It.IsAny <ISearchContext>())).Returns(() => new ReadOnlyCollection <IWebElement>(new List <IWebElement>()));

            var byEach = new ByEach(by1Mock.Object, by2Mock.Object, by3Mock.Object);

            Assert.Throws <NoSuchElementException>(() => byEach.FindElement(_webElementMock.Object));
        }
        public void FindElement_ShouldReturnFirstFoundElement()
        {
            var resultWebElementMock1 = new Mock <IWebElement>();
            var resultWebElementMock2 = new Mock <IWebElement>();
            var resultWebElementMock3 = new Mock <IWebElement>();

            var result1List = new List <IWebElement>()
            {
                resultWebElementMock1.Object, resultWebElementMock2.Object
            };
            var result2List = new List <IWebElement>()
            {
                resultWebElementMock3.Object, resultWebElementMock2.Object, resultWebElementMock1.Object
            };
            var result3List = new List <IWebElement>()
            {
                resultWebElementMock2.Object, resultWebElementMock1.Object
            };

            var by1Mock = new Mock <OpenQA.Selenium.By>();

            by1Mock.Setup(by => by.FindElements(It.IsAny <ISearchContext>())).Returns(() => new ReadOnlyCollection <IWebElement>(result1List));

            var by2Mock = new Mock <OpenQA.Selenium.By>();

            by2Mock.Setup(by => by.FindElements(It.IsAny <ISearchContext>())).Returns(() => new ReadOnlyCollection <IWebElement>(result2List));

            var by3Mock = new Mock <OpenQA.Selenium.By>();

            by3Mock.Setup(by => by.FindElements(It.IsAny <ISearchContext>())).Returns(() => new ReadOnlyCollection <IWebElement>(result3List));

            var byEach = new ByEach(by1Mock.Object, by2Mock.Object, by3Mock.Object);

            var resultElement = byEach.FindElement(_webElementMock.Object);

            Assert.AreSame(resultWebElementMock1.Object, resultElement);
        }