コード例 #1
0
        public static void PopulateAddressSection(string line1, string line2, string postalCode, string city, string state, string country, 
            string textBoxXPath, string dropDownListXPath, string xPathForBlankSpace, AddressSection.SupportedType type)
        {
            var textBoxFields = new Dictionary<string, string>
            {
                {FormatLabel(Line1Label, type), line1},
                //{FormatLabel(Line2Label, type), line2},
                {FormatLabel(PostalCodeLabel, type), postalCode},
               //{FormatLabel(CityLabel, type), city}
            };

            foreach (var kvp in textBoxFields)
            {
                var key = string.Format(textBoxXPath, kvp.Key);
                var element = Main.Driver.FindElement(By.XPath(key));

                if (element == null)
                    throw new Exception(string.Format("SetAddress: FAILED to find {0}!!", key));

                element.SendKeys(kvp.Value);

                //I am clicking into a blank text box so the system can 
                Main.Driver.FindElement(By.XPath(xPathForBlankSpace)).Click();
                //Driver.Instance.FindElement(By.XPath("//td/label[text()='Billing Contact:']/following::td[1]/input")).Click();
            }

            //var dropDownListFields = new Dictionary<string, string>
            //{
            //    {FormatLabel(StateLabel, type), state},
            //    {FormatLabel(CountryLabel, type), country}
            //};

            //foreach (var kvp in dropDownListFields)
            //{
              
            //    var key = string.Format(dropDownListXPath, kvp.Key);
            //    var element = Driver.Instance.FindElement(By.XPath(key));

            //    if (element == null)
            //        throw new Exception(string.Format("SetAddress: FAILED to find {0}!!", key));

            //    element.SendKeys(kvp.Value);
            //}
        }
コード例 #2
0
 private static string FormatLabel(string label, AddressSection.SupportedType type)
 {
     return string.Format("{0} {1}", type, label);
 }