Ejemplo n.º 1
0
        public void IsMultiSelectTest()
        {
            var elementActions = new ElementActions(Driver);

            Driver.Url = "http://automate-apps.com/select-multiple-options-from-a-drop-down-list/";
            elementActions.SelectDropdownValueByText(By.XPath("//select[@name='cars']"), "Honda");
            elementActions.SelectDropdownValueByText(By.XPath("//select[@name='cars']"), "BMW");
            Assert.IsTrue(elementActions.GetAllSelectedOptions(Driver.FindElement(By.XPath("//select[@name='cars']"))).Count == 2, "The total selected dropdown options wasn't 2.");
        }
Ejemplo n.º 2
0
        public void GetSelectedOptionIWebElementTest()
        {
            var elementActions = new ElementActions(Driver);

            Driver.Url = "http://automate-apps.com/select-multiple-options-from-a-drop-down-list/";
            elementActions.SelectDropdownValueByText(By.XPath("//select[@name='cars']"), "Honda");
            Assert.AreEqual("Honda", elementActions.GetSelectedOption(Driver.FindElement(By.XPath("//select[@name='cars']"))).Text, "The selected options didn't match.");
        }
Ejemplo n.º 3
0
        public void SelectDropdownValueByTextIWebElementTest()
        {
            var elementActions = new ElementActions(Driver);

            Driver.Url = "http://the-internet.herokuapp.com/";
            elementActions.Click(Driver.FindElement(By.XPath("//a[text()='Dropdown']")));
            elementActions.SelectDropdownValueByText(Driver.FindElement(By.Id("dropdown")), "Option 1");
            Assert.AreEqual("Option 1", elementActions.GetSelectedOption(Driver.FindElement(By.Id("dropdown"))).Text, "The selected dropdown values didn't match.");
        }
Ejemplo n.º 4
0
        public void DeselectDropdownValueByValueIndexTest()
        {
            var elementActions = new ElementActions(Driver);

            Driver.Url = "http://automate-apps.com/select-multiple-options-from-a-drop-down-list/";
            elementActions.SelectDropdownValueByText(By.XPath("//select[@name='cars']"), "BMW");
            Assert.AreEqual("BMW", elementActions.GetSelectedOption(By.XPath("//select[@name='cars']")).Text, "The selected dropdown values didn't match.");
            elementActions.DeselectDropdownValueByIndex(Driver.FindElement(By.XPath("//select[@name='cars']")), 2);
            Assert.IsNull(elementActions.GetSelectedOption(By.XPath("//select[@name='cars']")), "The selected dropdown option wasn't null.");
        }