Exemple #1
0
        //To do
        public static IControl GetReasonForChangeField(CRFTableQuestionsData Data, IControl TableRow)
        {
            string parentPath = DL_PatientsPage.GetFlatQuestionAnswerCellXpath(Data.QuestionPrompt);

            try
            {
                if (Data.AnswerFieldType.ToUpper() == "LISTBOX")
                {
                    IWebElement ListBox = TableRow.WebElement.FindElement(By.XPath(".//td[text()='" + Data.QuestionPrompt + "']/parent::tr/descendant::select[2]"));
                    return(new Control(ListBox, new SelectElement(ListBox)));
                }
                else
                {
                    IWebElement ListBox = TableRow.WebElement.FindElement(By.XPath(".//td[text()='" + Data.QuestionPrompt + "']/parent::tr/descendant::select"));
                    return(new Control(ListBox, new SelectElement(ListBox)));
                }
            }
            catch (Exception e)
            {
                //Fail statements
                return(null);
            }
        }
Exemple #2
0
        public static IControl GetAnswerFieldFromTableRow(IControl TableRow, CRFTableQuestionsData QuestionData)
        {
            IWebElement Field = null;

            try
            {
                IControl QElement = GetTableQuestionElement(TableRow, QuestionData.QuestionPrompt.Replace("&#x20", " "));
                if (QElement == null || QElement.WebElement == null)
                {
                    return(null);
                }
                switch (QuestionData.AnswerFieldType.ToUpper())
                {
                case "TEXTBOX":
                case "TEXT BOX":
                    Field = QElement.WebElement.FindElement(By.XPath("./descendant::input"));
                    break;

                case "LISTBOX":
                case "LIST BOX":
                    if (QuestionData.CurrentAnswerValue == null)
                    {
                        IWebElement ListBox = QElement.WebElement.FindElement(By.XPath("./descendant::select"));
                        return(new Control(ListBox, new SelectElement(ListBox)));
                    }
                    else
                    {
                        IWebElement ListBox = QElement.WebElement.FindElement(By.XPath("./descendant::select[1]"));
                        return(new Control(ListBox, new SelectElement(ListBox)));
                    }

                case "RADIOBUTTON":
                case "RADIO BUTTON":
                case "RADIO":
                case "CHECKBOX":
                case "CHECK BOX":
                    if (!String.IsNullOrEmpty(QuestionData.AnswerValue))
                    {
                        Field = QElement.WebElement.FindElement(By.XPath(".//label[text()='" + QuestionData.AnswerValue + "']/preceding-sibling::input"));
                    }
                    else if (!String.IsNullOrEmpty(QuestionData.NewAnswerValue))
                    {
                        Field = QElement.WebElement.FindElement(By.XPath(".//label[text()='" + QuestionData.NewAnswerValue + "']/preceding-sibling::input"));
                    }
                    else
                    {
                        Field = QElement.WebElement.FindElement(By.TagName("input"));
                    }
                    break;

                case "TEXTAREA":
                case "TEXT AREA":
                    Field = QElement.WebElement.FindElement(By.XPath("./descendant::textarea"));
                    break;

                case "LINK":
                    if (QuestionData.AnswerValue != null)
                    {
                        Field = QElement.WebElement.FindElement(By.XPath("./descendant::a[contains(text(), '" + QuestionData.AnswerValue + "') or @id]"));
                    }
                    else
                    {
                        Field = QElement.WebElement.FindElement(By.XPath("./descendant::a[contains(text(), '" + QuestionData.NewAnswerValue + "') or @id]"));
                    }
                    break;

                case "TEXT":
                    Field = QElement.WebElement.FindElement(By.XPath("./descendant::span"));
                    break;

                case "DISABLEDTEXT1":
                    Field = QElement.WebElement.FindElement(By.XPath("//descendant::input[contains(@class, 'disabled')]"));
                    break;

                case "IMAGE":
                    if (QuestionData.AnswerValue != null)
                    {
                        Field = QElement.WebElement.FindElement(By.XPath("./descendant::img[contains(@src,'" + QuestionData.AnswerValue + "')]"));
                    }
                    else
                    {
                        Field = QElement.WebElement.FindElement(By.XPath("./descendant::img[contains(@src,'" + QuestionData.NewAnswerValue + "')]"));
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                //fail case
            }
            return(new Control(Field));
        }