コード例 #1
0
ファイル: Settings.cs プロジェクト: ProjectAgri20/newrepo
        private void ok_Button_Click(object sender, EventArgs e)
        {
            if (keys_DataGridView.Enabled)
            {
                HashSet <string> keys = new HashSet <string>();

                foreach (SiteMapDataSet.KeysRow row in siteMapDataSet.Keys.Rows)
                {
                    if (!row.IsKey1Null() && !string.IsNullOrWhiteSpace(row.Key1))
                    {
                        keys.Add(row.Key1);
                    }

                    if (!row.IsKey2Null() && !string.IsNullOrWhiteSpace(row.Key2))
                    {
                        keys.Add(row.Key2);
                    }

                    if (!row.IsKey3Null() && !string.IsNullOrWhiteSpace(row.Key3))
                    {
                        keys.Add(row.Key3);
                    }
                }

                MasterKeys.Instance().SetKeys(keys);
            }
            else
            {
                GlobalSettings.Items.Add("EwsSitemapLocation", location_TextBox.Text);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #2
0
        private void LoadPageDetails()
        {
            try
            {
                foreach (string key in MasterKeys.Instance().GetKeys())
                {
                    keys_ComboBox.Items.Add(key);
                }

                keys_ComboBox.SelectedItem = _pageNode.Attributes["key"].Value;
                path_TextBox.Text          = _pageNode.Attributes["relative_path"].Value;

                foreach (XmlNode node in _pageNode.SelectNodes("Elements/Element"))
                {
                    SiteMapDataSet.SiteMapsRow row = siteMapDataSet.SiteMaps.NewSiteMapsRow();
                    row.Key  = node.Attributes["key"].Value;
                    row.ID   = node.Attributes["id"].Value;
                    row.Name = node.Attributes["name"].Value;

                    if (null != node.Attributes["xpath"])
                    {
                        row.XPath = node.Attributes["xpath"].Value;
                    }
                    else
                    {
                        row.XPath = string.Empty;
                    }

                    if (null != node.Attributes["class"])
                    {
                        row.Class = node.Attributes["class"].Value;
                    }
                    else
                    {
                        row.Class = string.Empty;
                    }

                    row.Type = node.Attributes["type"].Value;

                    siteMapDataSet.SiteMaps.AddSiteMapsRow(row);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in loading page {0} details".FormatWith(_pageNode.Attributes["relative_path"].Value));
            }
        }
コード例 #3
0
ファイル: Settings.cs プロジェクト: ProjectAgri20/newrepo
        private void LoadUI()
        {
            try
            {
                location_TextBox.Text = GlobalSettings.Items["EWSSitemapLocation"];

                HashSet <string> keys = MasterKeys.Instance().GetKeys();

                int res;

                int rem = Math.DivRem(keys.Count, 3, out res);

                int i = 0;

                for (int row = 0; row < rem; row++)
                {
                    SiteMapDataSet.KeysRow keyRow = siteMapDataSet.Keys.NewKeysRow();

                    keyRow.Key1 = keys.ElementAt(i++);
                    keyRow.Key2 = keys.ElementAt(i++);
                    keyRow.Key3 = keys.ElementAt(i++);

                    siteMapDataSet.Keys.AddKeysRow(keyRow);
                }

                if (res > 0)
                {
                    SiteMapDataSet.KeysRow row2 = siteMapDataSet.Keys.NewKeysRow();

                    if (res == 1)
                    {
                        row2.Key1 = keys.ElementAt(keys.Count - 1);
                    }
                    else if (res == 2)
                    {
                        row2.Key1 = keys.ElementAt(keys.Count - 2);
                        row2.Key2 = keys.ElementAt(keys.Count - 1);
                    }

                    siteMapDataSet.Keys.AddKeysRow(row2);
                }
            }
            catch (SettingNotFoundException)
            {
                keys_DataGridView.Enabled = false;
            }
        }
コード例 #4
0
        public void Validate(SeleniumWebDriver selenium, string deviceAddress)
        {
            this.Expand();

            // validate Page Key
            if (MasterKeys.Instance().IsExists(keys_ComboBox.Text))
            {
                keys_ComboBox.BackColor = Color.White;
            }
            else
            {
                keys_ComboBox.BackColor = Color.Red;
            }

            // validate Page relative path
            try
            {
                string url = path_TextBox.Text;

                if (!url.StartsWith("http", StringComparison.OrdinalIgnoreCase))
                {
                    url = "http://{0}/{1}".FormatWith(deviceAddress, url);
                }

                selenium.Open(new Uri(url));
                path_TextBox.BackColor = Color.White;
            }
            catch (Exception)
            {
                path_TextBox.BackColor = Color.Red;
            }

            int index = 0;

            // validate all the page elements
            foreach (SiteMapDataSet.SiteMapsRow row in siteMapDataSet.SiteMaps.Rows)
            {
                DataGridViewRow gridRow = pageDetails_DataGridView.Rows[index++];

                gridRow.Cells[1].Style.BackColor = Color.White;
                gridRow.Cells[2].Style.BackColor = Color.White;
                gridRow.Cells[3].Style.BackColor = Color.White;

                // validate they key
                if (MasterKeys.Instance().IsExists(row.Key))
                {
                    gridRow.Cells[0].Style.BackColor = Color.White;
                }
                else
                {
                    gridRow.Cells[0].Style.BackColor = Color.Red;
                }

                // validate id
                if (IsElementExists(selenium, row.ID, FindType.ById))
                {
                    gridRow.Cells[1].Style.BackColor = Color.White;
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(row.ID))
                    {
                        gridRow.Cells[1].Style.BackColor = Color.Red;
                    }
                    else
                    {
                        // validate name
                        if (IsElementExists(selenium, row.Name, FindType.ByName))
                        {
                            gridRow.Cells[2].Style.BackColor = Color.White;
                        }
                        else
                        {
                            if (!string.IsNullOrWhiteSpace(row.Name))
                            {
                                gridRow.Cells[2].Style.BackColor = Color.Red;
                            }
                            else
                            {
                                // validate xpath
                                if (IsElementExists(selenium, row.XPath, FindType.ByXPath))
                                {
                                    gridRow.Cells[3].Style.BackColor = Color.White;
                                }
                                else
                                {
                                    if (!string.IsNullOrWhiteSpace(row.XPath))
                                    {
                                        gridRow.Cells[3].Style.BackColor = Color.Red;
                                    }
                                    else
                                    {
                                        // validate class
                                        if (IsElementExists(selenium, row.Class, FindType.ByClassName))
                                        {
                                            gridRow.Cells[4].Style.BackColor = Color.White;
                                        }
                                        else
                                        {
                                            gridRow.Cells[4].Style.BackColor = Color.Red;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }