Example #1
0
        /// <summary>
        /// Implements the test logic for checking if selected goods fulfill selected criteria
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="item"></param>
        /// <param name="selected_criteria_set"></param>
        public static void CheckCriteria(IWebDriver driver, IWebElement item, Dictionary <Enum, List <Enum> > selected_criteria_set)
        {
            //this is done so that we can get to a link that shall be opened in a new tab
            IWebElement link_item = item.FindElement(By.ClassName("g-i-tile-i-title"));

            link_item = link_item.FindElement(By.TagName("a"));

            //and it shall be opened in a new tab
            link_item.OpenLinkInNewTab(driver);

            //and we navigate to that new tab which is to the right
            driver.SwitchTabRight();

            //Initialize the POM for the properties of the good
            GoodTitlePage      good_title_page      = new GoodTitlePage(driver);
            GoodPropertiesPage good_properties_page = good_title_page.OpenAllPropertiesPage(driver);

            //we assume that goods properties match the criteria
            bool properties_match = true;

            //We break up the properties page into property-name-property-value pairs by a classname
            ReadOnlyCollection <IWebElement> property_pairs =
                good_properties_page.contProperties.FindElements(By.ClassName("pp-characteristics-tab-i"));

            //And turn it into a dictionary
            Dictionary <string, string> title_value_pairs = new Dictionary <string, string>();

            foreach (IWebElement property_pair in property_pairs)
            {
                string title = property_pair.FindElement(By.ClassName("pp-characteristics-tab-i-title")).Text;
                string value = property_pair.FindElement(By.ClassName("pp-characteristics-tab-i-field")).Text;

                //by shoving title and value in it
                title_value_pairs.Add(title, value);
            }

            //now for EACH criterion (cojunction)
            foreach (Filters key in selected_criteria_set.Keys)
            {
                //if there was no such selected option that products values could fulfill then local_match is false and so is properties match from now on
                properties_match = properties_match && AssertProperties(good_properties_page.txGoodTitle.Text, key, title_value_pairs, selected_criteria_set);
            }

            //finally we check if the properties did indeed match, that is if properties_match is true
            Assert.IsTrue(properties_match);

            //Lastly close current tab
            driver.CloseCurrentTab();
        }
Example #2
0
 /// <summary>
 /// Method for switching to the properties tab of the good
 /// </summary>
 /// <param name="good_title_page"></param>
 /// <param name="driver"></param>
 /// <returns></returns>
 public static GoodPropertiesPage OpenAllPropertiesPage(this GoodTitlePage good_title_page, IWebDriver driver)
 {
     good_title_page.lnkAllProperties.Click(); //select the "Characteristics" tab
     Thread.Sleep(LoadingTimeout);             //wait for it to load
     return(new GoodPropertiesPage(driver));   //create a POM and return
 }
Example #3
0
        /// <summary>
        /// Implements the test logic for checking if selected goods fulfill selected criteria
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="item"></param>
        /// <param name="selected_criteria_set"></param>
        public static void CheckCriteria(IWebDriver driver, IWebElement item, Dictionary<Enum, List<Enum>> selected_criteria_set)
        {
            //this is done so that we can get to a link that shall be opened in a new tab
            IWebElement link_item = item.FindElement(By.ClassName("g-i-tile-i-title"));
            link_item = link_item.FindElement(By.TagName("a"));

            //and it shall be opened in a new tab
            link_item.OpenLinkInNewTab(driver);

            //and we navigate to that new tab which is to the right
            driver.SwitchTabRight();

            //Initialize the POM for the properties of the good
            GoodTitlePage good_title_page = new GoodTitlePage(driver);
            GoodPropertiesPage good_properties_page = good_title_page.OpenAllPropertiesPage(driver);

            //we assume that goods properties match the criteria
            bool properties_match = true;

            //We break up the properties page into property-name-property-value pairs by a classname
            ReadOnlyCollection<IWebElement> property_pairs =
                good_properties_page.contProperties.FindElements(By.ClassName("pp-characteristics-tab-i"));

            //And turn it into a dictionary
            Dictionary<string, string> title_value_pairs = new Dictionary<string, string>();
            foreach (IWebElement property_pair in property_pairs)
            {
                string title = property_pair.FindElement(By.ClassName("pp-characteristics-tab-i-title")).Text;
                string value = property_pair.FindElement(By.ClassName("pp-characteristics-tab-i-field")).Text;

                //by shoving title and value in it
                title_value_pairs.Add(title, value);
            }

            //now for EACH criterion (cojunction)
            foreach (Filters key in selected_criteria_set.Keys)
            {
                //if there was no such selected option that products values could fulfill then local_match is false and so is properties match from now on
                properties_match = properties_match && AssertProperties(good_properties_page.txGoodTitle.Text, key, title_value_pairs, selected_criteria_set);
            }

            //finally we check if the properties did indeed match, that is if properties_match is true
            Assert.IsTrue(properties_match);

            //Lastly close current tab
            driver.CloseCurrentTab();
        }