Esempio n. 1
0
        bool selenium_command(SeleniumAction action, string param, string param2, bool compare)
        {
            try
            {
                switch (action)
                {
                case SeleniumAction.Open:
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium1_url, param, param2);
                    selenium1.Open(param);
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium2_url, param, param2);
                    selenium2.Open(param);
                    break;

                case SeleniumAction.Click:
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium1_url, param, param2);
                    selenium1.Click(param);
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium2_url, param, param2);
                    selenium2.Click(param);
                    break;

                case SeleniumAction.WaitForPageToLoad:
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium1_url, param, param2);
                    selenium1.WaitForPageToLoad(param);
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium2_url, param, param2);
                    selenium2.WaitForPageToLoad(param);
                    break;

                case SeleniumAction.Type:
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium1_url, param, param2);
                    selenium1.Type(param, param2);
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium2_url, param, param2);
                    selenium2.Type(param, param2);
                    break;

                case SeleniumAction.GoBack:
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium1_url, param, param2);
                    selenium1.GoBack();
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium2_url, param, param2);
                    selenium2.GoBack();
                    break;

                case SeleniumAction.Select:
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium1_url, param, param2);
                    selenium1.Select(param, param2);
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium2_url, param, param2);
                    selenium2.Select(param, param2);
                    break;

                case SeleniumAction.AddSelection:
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium1_url, param, param2);
                    selenium1.AddSelection(param, param2);
                    Console.WriteLine("action={0} host={1} param={2},{3}", action.ToString(), selenium2_url, param, param2);
                    selenium2.AddSelection(param, param2);
                    break;
                }
                if (compare)
                {
                    return(compare_result(String.Format("action={0} param={1},{2}", action.ToString(), param, param2)));
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ee)
            {
                Console.WriteLine("Exception: action={0} param={1},{2} message={3}", action.ToString(), param, param2, ee.Message);
                Console.WriteLine("Press any key to conitnue......");
                Console.ReadKey();
                //ConsoleKeyInfo key = Console.ReadKey();
                //if (key.Key == CosoleKey.Escape)
                //{
                //}
                return(false);
            }
        }