Ejemplo n.º 1
0
        public void ShouldAdd()
        {
            StringAssert.AreEqualIgnoringCase(ngDriver.Title, "Super Calculator");

            var ng_first_operand = ngDriver.FindElement(NgBy.Model("first"));

            ng_first_operand.SendKeys("1");

            NgWebElement ng_second_operand = ngDriver.FindElement(NgBy.Input("second"));

            ng_second_operand.SendKeys("2");

            NgWebElement ng_math_operator_element = ngDriver.FindElement(NgBy.Options("value for (key, value) in operators"));

            Assert.AreEqual(ng_math_operator_element.Text, "+");

            IWebElement math_operator_element = ngDriver.FindElement(NgBy.SelectedOption("operator"));

            Assert.AreEqual(math_operator_element.Text, "+");

            IWebElement go_button_element = ngDriver.FindElement(NgBy.PartialButtonText("Go"));

            Assert.IsTrue(go_button_element.Displayed);

            var ng_go_button_element = ngDriver.FindElement(By.Id("gobutton"));

            ng_go_button_element.Click();

            NgWebElement result_element = ngDriver.FindElement(NgBy.Binding("latest"));

            Assert.AreEqual("3", result_element.Text);
            highlight(result_element, 1000);
        }
        public void ShouldDropDown()
        {
            GetPageContent("ng_dropdown.htm");
            string optionsCountry = "country for (country, states) in countries";
            ReadOnlyCollection <NgWebElement> ng_countries = ngDriver.FindElements(NgBy.Options(optionsCountry));

            Assert.IsTrue(4 == ng_countries.Count);
            Assert.IsTrue(ng_countries[0].Enabled);
            string       optionsState = "state for (state,city) in states";
            NgWebElement ng_state     = ngDriver.FindElement(NgBy.Options(optionsState));

            Assert.IsFalse(ng_state.Enabled);
            SelectElement countries = new SelectElement(ngDriver.FindElement(NgBy.Model("states")).WrappedElement);

            countries.SelectByText("Australia");
            Thread.Sleep(1000);
            Assert.IsTrue(ng_state.Enabled);
            NgWebElement ng_selected_country = ngDriver.FindElement(NgBy.SelectedOption(optionsCountry));
            // TODO:debug (works in Java client)
            // Assert.IsNotNull(ng_selected_country.WrappedElement);
            // ng_countries = ngDriver.FindElements(NgBy.Options(optionsCountry));
            NgWebElement ng_country = ng_countries.First(o => o.Selected);

            StringAssert.IsMatch("Australia", ng_country.Text);
        }
Ejemplo n.º 3
0
        public void ShouldFindSelectedtOption()
        {
            Common.GetLocalHostPageContent("ng_select_array.htm");
            NgWebElement ng_element = ngDriver.FindElement(NgBy.SelectedOption("myChoice"));

            StringAssert.IsMatch("three", ng_element.Text);
            Assert.IsTrue(ng_element.Displayed);
        }
Ejemplo n.º 4
0
 public void ProtractorTestUsingCSharp()
 {
     ngDriver.FindElement(NgBy.Binding("BindingName")).Click();
     ngDriver.FindElement(NgBy.Model("ModelName")).SendKeys("Text");
     ngDriver.FindElement(NgBy.Repeater("Value")).Click();
     ngDriver.FindElement(NgBy.SelectedOption("Options")).Click();
     ngDriver.FindElement(By.ClassName("ClassName")).SendKeys("Text");
     ngDriver.FindElement(By.TagName("Tag")).Click();
     ngDriver.FindElement(By.CssSelector("#CssSelector")).Click();
     ngDriver.FindElement(By.Id("Id")).Click();
 }
Ejemplo n.º 5
0
        public void ShouldChangeSelectedtOption()
        {
            Common.GetLocalHostPageContent("ng_select_array.htm");
            ReadOnlyCollection <NgWebElement> ng_elements = ngDriver.FindElements(NgBy.Repeater("option in options"));
            NgWebElement ng_element = ng_elements.First(o => String.Compare("two", o.Text,
                                                                            StringComparison.InvariantCulture) == 0);

            ng_element.Click();
            string text = ng_element.Text;

            // to trigger WaitForAngular
            Assert.IsTrue(ng_element.Displayed);

            ng_element = ngDriver.FindElement(NgBy.SelectedOption("myChoice"));
            StringAssert.IsMatch(text, ng_element.Text);
            Assert.IsTrue(ng_element.Displayed);
        }
Ejemplo n.º 6
0
        public void ShouldChangeSelectedtOption()
        {
            ReadOnlyCollection <NgWebElement> options = ngDriver.FindElements(NgBy.Repeater("option in options"));
            var options_enumerator = options.GetEnumerator();

            options_enumerator.Reset();
            while (options_enumerator.MoveNext())
            {
                NgWebElement option = (NgWebElement)options_enumerator.Current;
                if (option.Text.Equals("two", StringComparison.Ordinal))
                {
                    option.Click();
                }
            }
            NgWebElement element = ngDriver.FindElement(NgBy.SelectedOption("myChoice"));

            StringAssert.IsMatch("two", element.Text);
        }
Ejemplo n.º 7
0
        public void ShouldDropDownWatch()
        {
            Common.GetLocalHostPageContent("ng_dropdown_watch.htm");
            string optionsCountry = "country for country in countries";
            ReadOnlyCollection <NgWebElement> ng_countries = ngDriver.FindElements(NgBy.Options(optionsCountry));

            Assert.IsTrue(3 == ng_countries.Count);
            Assert.IsTrue(ng_countries[0].Enabled);
            string       optionsState = "state for state in states";
            NgWebElement ng_state     = ngDriver.FindElement(NgBy.Options(optionsState));

            Assert.IsFalse(ng_state.Enabled);
            SelectElement countries = new SelectElement(ngDriver.FindElement(NgBy.Model("country")).WrappedElement);

            countries.SelectByText("china");
            Thread.Sleep(1000);
            Assert.IsTrue(ng_state.Enabled);
            NgWebElement ng_selected_country = ngDriver.FindElement(NgBy.SelectedOption("country"));

            Assert.IsNotNull(ng_selected_country.WrappedElement);
            NgWebElement ng_country = ng_countries.First(o => o.Selected);

            StringAssert.IsMatch("china", ng_country.Text);
        }
Ejemplo n.º 8
0
        public void ShouldFindSelectedtOption()
        {
            NgWebElement element = ngDriver.FindElement(NgBy.SelectedOption("myChoice"));

            StringAssert.IsMatch("three", element.Text);
        }