示例#1
0
        private string GetHrefCTA(WesofHtmlTag value)
        {
            string searchFor  = "href=\"";
            int    startindex = value.fullTagString.IndexOf(searchFor) + searchFor.Length;

            if (startindex > -1)
            {
                int endindex = value.fullTagString.IndexOf("\"", startindex);
                if (endindex > -1)
                {
                    string result = value.fullTagString.Substring(startindex, endindex - startindex);

                    //href type CTA found
                    if (result.Length > 0)
                    {
                        //Is this tag stil relevant (testable), then add the href to the conversion triggers.
                        if (value.testingEnabled == true)
                        {
                            ConversionTrigger trigger = new ConversionTrigger();
                            trigger.Href = result;

                            if (value.objectType.ToUpper() == Configuration.MVT_MODULES_LIST[0].ToUpper())
                            {
                                trigger.TestType = TestTypesEnum.ADDTOCARTBUTTON;
                            }

                            ConversionManager.AddConversionTriggerIfnotExists(trigger);
                        }
                    }
                }
            }

            return(null);
        }
示例#2
0
        /// <summary>
        /// This method should work like a hub to match the object types to the appropriate handling modules.
        /// However, this now only looks for the AddToCartButton type, as no other will be implemented.
        /// (This method will need change when new modules/test types are implemented)
        /// </summary>
        public void SendTagsToMatchingMvtModules()
        {
            if (_Tags.First == null)
            {
                return;
            }

            WesofHtmlTag[] addToCartButtons;

            //Count up the number of testable "add to cart" CTA objects
            int countEnabledAddToButtonTypeObjects = 0;
            LinkedListNode <WesofHtmlTag> iterator = _Tags.First;

            while (iterator != null)
            {
                if (iterator.Value.testingEnabled == true && iterator.Value.objectType.ToUpper() == Configuration.MVT_MODULES_LIST[0].ToUpper())
                {
                    countEnabledAddToButtonTypeObjects++;
                }
                iterator = iterator.Next;
            }

            //Instantiate an array for testable "add to cart" CTA objects
            if (countEnabledAddToButtonTypeObjects > 0)
            {
                addToCartButtons = new WesofHtmlTag[countEnabledAddToButtonTypeObjects];
                int index = 0;

                //Iterate through the LL again and add the tags to the array
                iterator = _Tags.First;
                while (iterator != null)
                {
                    if (iterator.Value.testingEnabled == true && iterator.Value.objectType.ToUpper() == Configuration.MVT_MODULES_LIST[0].ToUpper())
                    {
                        addToCartButtons[index] = iterator.Value;
                        index++;
                    }
                    iterator = iterator.Next;
                }

                //We have all testable addToCartButtons in an array. Let's pass them to the test manager.
                Configuration.MainController.GetTestManager().HandleAddToCartCTATags(addToCartButtons, ref _sRep);
            }
            else
            {
                return;
            }
        }
示例#3
0
        private HtmlCommentTag GetNextHTMLWeSofTag(int startPos, ref string htmlText)
        {
            WesofHtmlTag result = null;

            //Finds the next HTML comment start
            int start = FindHtmlCommentTag(startPos, true, ref htmlText);
            int end   = -1;

            //Finds the comment end
            if (start > -1)
            {
                end = FindHtmlCommentTag(start, false, ref htmlText);
            }


            //If tag found, checks if it is a WESOF start tag
            if (end > -1)
            {
                if (IsHtmlTagWeSofTag(ref htmlText, start, end, true))
                {
                    //It was a WeSOF start tag.
                    result                  = new WesofHtmlTag();
                    result.isWesofTag       = true;
                    result.startIndex       = start;
                    result.startTagendIndex = end;
                    result.startTagString   = htmlText.Substring(start, end - start);

                    //Search for the closing tag
                    int  closingStart;
                    int  closingEnd;
                    bool isWesofTagStop = false;

                    //Search closing tags
                    int searchForEndFrom = end;
                    do
                    {
                        //Find first opening html comment tag
                        closingStart = FindHtmlCommentTag(searchForEndFrom, true, ref htmlText);
                        if (closingStart > -1)
                        {
                            //Find the end of the comment tag
                            closingEnd = FindHtmlCommentTag(closingStart, false, ref htmlText);
                            if (closingEnd > -1)
                            {
                                //Check if this was WeSOF closing tag
                                isWesofTagStop = IsHtmlTagWeSofTag(ref htmlText, closingStart, closingEnd, false);

                                if (isWesofTagStop)
                                {
                                    result.closingTagStartIndex = closingStart;
                                    result.closingTagEndIndex   = closingEnd;
                                    result.fullTagString        = htmlText.Substring(start, closingEnd - start);
                                    result.contentBetweenTags   = htmlText.Substring(end, closingStart - end);

                                    return(result);
                                }
                                else
                                {
                                    //Start look for a new HTML tag from the last html comment end.
                                    searchForEndFrom = closingEnd;
                                }
                            }
                            else
                            {
                                //No closing end found for an html comment. That's unlikely.
                                if (Configuration.IsDebugModeOn)
                                {
                                    _CLI.Out("Error. Cannot find closing for an HTML comment. Maybe the HTML file is invalid.");
                                }
                                return(null);
                            }
                        }
                    } while (closingStart > -1 && !isWesofTagStop);


                    if (isWesofTagStop)
                    {
                        return(result);
                    }
                }
                else
                {
                    //The found tag was a HTML comment, but not a WeSOF tag.
                    HtmlCommentTag commentFoundOnly = new HtmlCommentTag();
                    commentFoundOnly.isWesofTag       = false;
                    commentFoundOnly.startIndex       = start;
                    commentFoundOnly.startTagendIndex = end;
                    return(commentFoundOnly);
                }
            }

            return(null);
        }