public void FindByAccessibilityIdTest()
        {
            By byAccessibilityId = new ByAccessibilityId("ComputeSumButton");

            Assert.AreNotEqual(driver.FindElementsByClassName("UIAWindow")[1].FindElement(byAccessibilityId).Text, null);
            Assert.GreaterOrEqual(driver.FindElementsByClassName("UIAWindow")[1].FindElements(byAccessibilityId).Count, 1);
        }
Пример #2
0
        public void FindByAccessibilityIdTest()
        {
            By byAccessibilityId = new ByAccessibilityId("Graphics");

            Assert.AreNotEqual(_driver.FindElement(byAccessibilityId).Text, null);
            Assert.GreaterOrEqual(_driver.FindElements(byAccessibilityId).Count, 1);
        }
Пример #3
0
        public void FindElementTestCase()
        {
            By byAccessibilityId = new ByAccessibilityId("Graphics");

            Assert.AreNotEqual(driver.FindElement(byAccessibilityId).Text, null);
            Assert.GreaterOrEqual(driver.FindElements(byAccessibilityId).Count, 1);

            driver.FindElementByAccessibilityId("Graphics").Click();
            Assert.IsNotNull(driver.FindElementByAccessibilityId("Arcs"));
            driver.Navigate().Back();

            Assert.IsNotNull(driver.FindElementByName("App"));

            Assert.IsNotNull(driver.FindElement(new ByAndroidUIAutomator("new UiSelector().clickable(true)")).Text);
            var els = driver.FindElementsByAndroidUIAutomator("new UiSelector().clickable(true)");

            Assert.GreaterOrEqual(els.Count, 12);

            var els2 = driver.FindElements(new ByAndroidUIAutomator("new UiSelector().enabled(true)"));

            Assert.GreaterOrEqual(els2.Count, 20);

            els = driver.FindElementsByAndroidUIAutomator("new UiSelector().enabled(true)");
            Assert.GreaterOrEqual(els.Count, 20);
            Assert.IsNotNull(driver.FindElementByXPath("//android.widget.TextView[@text='API Demos']"));
        }
        public void AppiumDriverMethodsTestCase()
        {
            // Using appium extension methods
            // referenced https://github.com/appium-boneyard/sample-code/blob/master/sample-code/examples/dotnet/AppiumDotNetSample/Android/AndroidSearchingTest.cs#L53-L55
            var HOMEPAGE_HEADLINE        = "AWS Device Farm Sample App for Android";
            By  byAccessibilityId        = new ByAccessibilityId("Homepage Headline");
            var actual_homepage_headline = driver.FindElement(byAccessibilityId).Text;

            Assert.AreEqual(actual_homepage_headline, HOMEPAGE_HEADLINE);
        }
Пример #5
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            this.initDeskTopSession_Explicit();

            try
            {
                //close notepad
                //var find_element = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"Notepad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]");
                //string s_string = "닫기";
                string s_string     = "Close";
                var    find_element = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"Notepad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"" + s_string + "\"]");
                find_element.Click();

                var notepad_close_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(find_element));
                notepad_close_button.Click();

                var save_ignore_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(ByAccessibilityId.AccessibilityId("CommandButton_7")));
                save_ignore_button.Click();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Full Stacktrace: {0}", ex.ToString()));
            }
        }
Пример #6
0
        private void Button1_Click(object sender, EventArgs e)
        {
            //Close NotePad(NotePad 닫기)
            //    "/Pane[@ClassName=\"#32769\"][@Name=\"데스크톱 1\"]/Window[@ClassName=\"Notepad\"][@Name=\"*제목 없음 - Windows 메모장\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]"



            ////    //var gameElement = _deskTopSessoin.FindElementsByXPath("//ListItem[@ClassName=\"GridViewItem\"]/Button[@AutomationId=\"_rootGrid\"]/Image[@AutomationId=\"_image\"]");

            this.initDeskTopSession_Explicit();

            try
            {
                //아래 코드 테스트 문제 없음...
                //var element = _deskTopSession.FindElementByXPath("//Window[@Name=\"전원 관리 옵션 설정 편집\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]");
                //element.Click();

                //below is okay
                //var element = _deskTopSession.FindElementByXPath("//Window[@Name=\"*제목 없음 - Windows 메모장\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]");
                //element.Click();

                //below is Okay
                var find_element         = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"Notepad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]");
                var notepad_close_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(find_element));
                notepad_close_button.Click();

                var save_ignore_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(ByAccessibilityId.AccessibilityId("CommandButton_7")));
                save_ignore_button.Click();

                //element.Click();


                //var element = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"Notepad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@AutomationId=\"Close\"]");
                //element.Click();



                //var element = _deskTopSession.FindElementByXPath("//Window[@Name=\"*제목 없음 - Windows 메모장\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@AutomationId=\"Close\"]");
                //element.Click();

                //var find_element = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"NotePad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@AutomationId=\"Close\"]");
                //var find_element = _deskTopSession.FindElementByXPath("//Window[@Name=\"*제목 없음 - Windows 메모장\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]");
                //var notepad_close_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(find_element));
                //notepad_close_button.Click();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Full Stacktrace: {0}", ex.ToString()));
            }
        }
Пример #7
0
        void do_sendkey_verification()
        {
            //Faile이 날때 까지는 계속 수행
            //notepad app은 1번만 수행 시킨다.
            bool b_notepad_running = false;

            //Main Program Loop
            //Notice : SendKey Test에서 _test_result가 false가 되면, retry handling을 해도
            //복구가 안되기 때문에 전체 루틴을 종료 시킨다.

            do
            {
                //NotePad Loop
                try
                {
                    //exception test code
                    // int sum = 100;
                    // int tmp_value = sum / 0;

                    var element_search_area = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(ByAccessibilityId.AccessibilityId("4101")));
                    element_search_area.Click();

                    var element_search_textbox = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(ByAccessibilityId.AccessibilityId("SearchTextBox")));
                    element_search_textbox.Clear();
                    element_search_textbox.Click();
                    element_search_textbox.SendKeys(@"notepad");

                    //var element1 = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Name("검색하려면 여기에 입력하십시오.")));

                    //suggestionsList
                    //var find_element = _deskTopSession.FindElementByXPath("//Image[@AutomationId=\"suggestionsList\"]//child::ListItem[1]");
                    //var notepad_element = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(find_element));
                    var notepad_element = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//List[@AutomationId=\"suggestionsList\"]//child::ListItem[1]")));
                    notepad_element.Click();

                    b_notepad_running = true;
                    _notepad_counter  = _notepad_counter + 1;


                    Dictionary <string, object> item_info = new Dictionary <string, object>();
                    item_info.Add(_keyList.k_test_result, "pass");
                    item_info.Add(_keyList.k_test_scenario, "run notepad application");

                    //시간 업데이트
                    _taskEndTime = System.DateTime.Now;
                    s_endTime    = string.Format("{0:hh:mm:ss tt}", _taskEndTime);
                    item_info.Add(_keyList.k_end_time, s_endTime);

                    _sendkey_test_list.Add(item_info);

                    //여기서 UI Update
                    //worker.ReportProgress(10, update_info);
                    worker.ReportProgress(1); //여기서 1의 의미는 progress bar퍼세트용도가 아니라, 단순히 worker_ProgressChanged을 호출하기 위한 용도
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Full Stacktrace: {0}", ex.ToString()));

                    Dictionary <string, object> item_info = new Dictionary <string, object>();
                    item_info.Add(_keyList.k_test_result, "fail");
                    item_info.Add(_keyList.k_test_scenario, "run notepad application");

                    //시간 업데이트
                    _taskEndTime = System.DateTime.Now;
                    s_endTime    = string.Format("{0:hh:mm:ss tt}", _taskEndTime);
                    item_info.Add(_keyList.k_end_time, s_endTime);

                    _sendkey_test_list.Add(item_info);

                    _test_result = false;
                    _uiManager.txtBox_Exception.Text = ex.ToString();

                    //여기서 UI Update
                    worker.ReportProgress(1);


                    break; //이 브레이크를 사용하면 전체 루프가 종료 된다.
                }



                if (b_notepad_running)
                {
                    var edit_element = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.ClassName("Edit")));
                    edit_element.Click();

                    _success_counter = 0;
                    _test_result     = false;
                    do
                    {
                        try
                        {
                            //var edit_element = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.ClassName("Edit")));
                            //edit_element.Click();
                            //Thread.Sleep(1000); //키처리 시간 예상

                            edit_element.SendKeys("Hello WAD");
                            Thread.Sleep(2000); //키처리 시간 예상

                            edit_element.SendKeys(OpenQA.Selenium.Keys.Enter);
                            Thread.Sleep(2000); //키처리 시간 예상

                            //UI-Update진행할 것(현재 진행 결과를 데이터 구성해서 view로 업데이트)
                            //List는 모든것을 가지고 있다하더라도, View에서 업데이트할 때, 전체 List를 모두 갱신하는 것이 아니라,
                            //List의 최종 항목만 업데이트 하도록 변경하면 된다.

                            //에러가 없었으면 view에 업데이트할 항목을 구성하고 업데이트 한다.
                            //_testresult_columninfos.Add(_keyList.k_test_result);
                            //_testresult_columninfos.Add(_keyList.k_test_scenario);
                            //_testresult_columninfos.Add(_keyList.k_end_time);

                            Dictionary <string, object> item_info = new Dictionary <string, object>();
                            item_info.Add(_keyList.k_test_result, "pass");
                            item_info.Add(_keyList.k_test_scenario, "send string to notepad application");

                            //시간 업데이트
                            _taskEndTime = System.DateTime.Now;
                            s_endTime    = string.Format("{0:hh:mm:ss tt}", _taskEndTime);
                            item_info.Add(_keyList.k_end_time, s_endTime);

                            _sendkey_test_list.Add(item_info);

                            worker.ReportProgress(1);  //ui update


                            _test_result     = true;
                            _success_counter = _success_counter + 1;

                            //현재 Test결과 ListView로 업데이트.

                            //Calculate Current Time with using Utility Class
                            Thread.Sleep(1000); //for saving power consumption
                        }
                        catch (Exception ex)
                        {
                            System.Diagnostics.Debug.WriteLine(string.Format("Full Stacktrace: {0}", ex.ToString()));
                            Dictionary <string, object> item_info = new Dictionary <string, object>();
                            item_info.Add(_keyList.k_test_result, "fail");
                            item_info.Add(_keyList.k_test_scenario, "send string to notepad application");

                            //시간 업데이트
                            _taskEndTime = System.DateTime.Now;
                            s_endTime    = string.Format("{0:hh:mm:ss tt}", _taskEndTime);
                            item_info.Add(_keyList.k_end_time, s_endTime);

                            _sendkey_test_list.Add(item_info);

                            worker.ReportProgress(1); //ui update
                            _test_result = false;
                            _uiManager.txtBox_Exception.Text = ex.ToString();
                        }
                    } while (_success_counter < _testpass_number && _test_result != false);


                    //notepad종료(결과 상관없이 종료)
                    //TOAN : 06/30/2020. Current Display Language을 check하여 element구분함.
                    string s_string       = _uiManager.getCurrent_DisplayLanguage();
                    string element_string = "";

                    if (s_string.Equals("korea"))
                    {
                        element_string = "닫기";
                    }
                    else if (s_string.Equals("usa"))
                    {
                        element_string = "Close";
                    }


                    var find_element = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"Notepad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"" + element_string + "\"]");
                    //var find_element = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"Notepad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]");
                    var notepad_close_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(find_element));
                    notepad_close_button.Click();

                    var save_ignore_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(ByAccessibilityId.AccessibilityId("CommandButton_7")));
                    save_ignore_button.Click();
                }
            } while(_notepad_counter < _notepad_loop && _test_result != false);


            //Terminate while loop for
            if (_test_result == false)
            {
                //TO DO : Save Screen Shot
                string        dirName = @"C:\testautomation";
                DirectoryInfo di      = new DirectoryInfo(dirName);

                if (di.Exists == false)
                {
                    di.Create();
                }

                Screenshot screenshot = _deskTopSession.GetScreenshot();
                screenshot.SaveAsFile(@"C:\testautomation\screenshot.png");

                //TO DO : Memory Dump
                //URL참조: http://blog.naver.com/PostView.nhn?blogId=techshare&logNo=100194859982
                //File은 Filezilla로 전송.
                System.Diagnostics.Debug.WriteLine(string.Format("Current Test is Fail"));
            }
        } //end of sendKey verification
Пример #8
0
        //TOAN : 04/17/2020. Automation with Implicit Waiting time.
        void do_free_game_ranking()
        {
            //setup implicit wait time. Have to setup implicit wait time
            _deskTopSession.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(200);



            //FOZA Horizon demo확인해 볼것(너무 길다)
            //Thread.sleep을 하면, implicitwait, expllicitwait logic까지 영향을 받는듯 하다.

            //TOAN : 04/14/2020. Below is not generalization code

            //TOAN : 04/14/2020. Below is generalization code
            //this.compose_freegame_ranking();
            //this.operateTestScenario(_store_test_list);

            System.Diagnostics.Debug.WriteLine(string.Format("do free game ranking"));


            try
            {
                AppiumWebElement start_button = _deskTopSession.FindElement(By.Name("시작"));
                Thread.Sleep(2000);

                if (start_button != null)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Find StartBtn"));
                    start_button.Click();
                }

                //Thread.Sleep(3000);
                AppiumWebElement store_button = _deskTopSession.FindElementByAccessibilityId("tile-P~Microsoft.WindowsStore_8wekyb3d8bbwe!App");

                //Thread.Sleep(2000);
                if (store_button != null)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Find Store Btn"));
                    store_button.Click();
                }

                //여기까지 문제 없었으면 Store창이 정상적으로 display되어졌을 것이다.
                //Thread.Sleep(7000);
                AppiumWebElement gaming_button = _deskTopSession.FindElementByAccessibilityId("gaming");
                if (gaming_button != null)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Find gaming Btn"));
                    gaming_button.Click();
                }

                //Thread.Sleep(2000);
                //무료 인기 게임지정을 toefreegames,SectionViewAllButton조합으로 변경 진행 할 것
                //인기 유료 게임 : toppaidgames -> SectionViewAllButton조합으로 변경 할 것
                AppiumWebElement freegame_list = _deskTopSession.FindElement(By.Name("모두 표시 99/+  무료 인기 게임"));
                freegame_list.Click();

                //TOAN : 06/05/2020. code-change
                var           wait         = new WebDriverWait(_deskTopSession, new TimeSpan(0, 5, 0));
                List <string> _appList     = new List <string>();
                int           loop_counter = 0;


                var gameElements = _deskTopSession.FindElementsByXPath("//List[@AutomationId=\"AppList\"]//child::ListItem");
                //var currList = gameElement.ToList();

                //step2
                foreach (var currItem in gameElements)
                {
                    //string itemID = currItem.GetAttribute("AutomationId");
                    //currItem.GetAttribute("Name")
                    System.Diagnostics.Debug.WriteLine(string.Format("element name:{0}", currItem.GetAttribute("AutomationId")));
                    _appList.Add(currItem.GetAttribute("AutomationId").ToString());
                    //element.Click();
                }


                //foreach (var currItem in currList)
                foreach (string autoID in _appList)
                {
                    if (loop_counter >= 10)
                    {
                        break; //exit internal loop for testing
                    }
                    loop_counter = loop_counter + 1;

                    System.Diagnostics.Debug.WriteLine(string.Format("Data Fetch Logic Start:{0}", _myUtility.getCurrentTime()));

                    Dictionary <string, object> item_info = new Dictionary <string, object>();  //해당 아이템의 필요한 정보를 뽑아서 사전 형태로 저장

                    item_info.Add(_keyList.k_store_category, _categoryName);
                    item_info.Add(_keyList.k_store_subclass, _subclassName);

                    var celement = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(ByAccessibilityId.AccessibilityId(autoID)));
                    //var celement = _deskTopSession.FindElementByAccessibilityId(autoID);
                    //_deskTopSession.Mouse.MouseMove(celement.Coordinates);

                    System.Diagnostics.Debug.WriteLine(string.Format("App Name:{0}", celement.GetAttribute("Name")));
                    celement.Click();

                    //step1 : get App Title
                    System.Diagnostics.Debug.WriteLine(string.Format("DynamicHeading_productTitle Element Find Start:{0}", _myUtility.getCurrentTime()));
                    var    element  = _deskTopSession.FindElementByAccessibilityId("DynamicHeading_productTitle");
                    string itemName = element.GetAttribute("Name");

                    item_info.Add(_keyList.k_store_app_name, itemName.ToString());

                    //var elements = element.FindElementsByXPath("/following-sibling::*");
                    //var elements = _deskTopSession.FindElementsByXPath("//Text[@AutomationId=\"DynamicHeading_productTitle\"]/following-sibling::*"); //This is OK

                    //click한 이후에 형제 element들을 가지고 온다.
                    System.Diagnostics.Debug.WriteLine(string.Format("[형제]DynamicHeading_productTitle Sibling Find Start:{0}", _myUtility.getCurrentTime()));
                    var elements = _deskTopSession.FindElementsByXPath("//Text[@AutomationId=\"DynamicHeading_productTitle\"]//following-sibling::*"); //This is OK


                    //TOAN : 04/22/2020. 하위 element에 범주 자체가 없는 경우도 발생
                    //이경우는 개요 항목에서 "범주"를 다시 가지고 온다.
                    //category_string변수 위치 변경.
                    string category_string = "";

                    foreach (var currElement in elements)
                    {
                        // System.Diagnostics.Debug.WriteLine(string.Format("child name:{0}", currElement.GetAttribute("Name"))); //print all sibling member
                        //Step1 : Get Publisher
                        string currString = currElement.GetAttribute("Name");
                        System.Diagnostics.Debug.WriteLine(string.Format("current element name:{0}", currString));


                        if (!String.IsNullOrEmpty(currString))
                        {
                            if (currString.Equals("게시자"))
                            {
                                var    childElement   = currElement.FindElementByXPath("//child::Button");                                  //Get first button element
                                string publisher_name = childElement.GetAttribute("Name");
                                System.Diagnostics.Debug.WriteLine(string.Format("publisher name:{0}", childElement.GetAttribute("Name"))); //print all sibling member
                                item_info.Add(_keyList.k_sotre_app_manufacture, publisher_name);
                            }
                            //Step2 : Get Category
                            if (currString.Equals("범주"))
                            {
                                var childElements = currElement.FindElementsByXPath("//child::Button"); //Get All button elements
                                //string category_string = "";
                                category_string = "";
                                string suffix_string = "의 자세한 결과 보기";
                                int    suffix_length = suffix_string.Length; //범주에 "의 자세한 결과 보기"가 붙기 때문에, 해당 Title제거

                                //Store의 범주는 눈에 보여지는 string과 ui element가 가지고 있는 형태가 틀리다.
                                //예를 들어 Roblox의 경우 엑션 및 어드벤처,가족 및 어린이와 같이 표시되나.
                                //내부적으로는
                                //"액션 및 어드벤처의 자세한 결과 보기", "," ,"가족 및 어린이의 자세한 결과 보기"로 구성
                                //즉, 접미사 형태로 "자세한 결과 보기"가 포함되어 있다. 따라서 이것에 대해 substring작업을 통해 별도 처리 한다.
                                //위 작업은 suffix length와 substring을 통해 이루어 진다.


                                foreach (var currButton in childElements)
                                {
                                    //category_string = String.Right()
                                    if (!String.IsNullOrEmpty(category_string))
                                    {
                                        string element_name = currButton.GetAttribute("Name");
                                        category_string = category_string + "," + element_name.Substring(0, element_name.Length - suffix_length);
                                    }
                                    else
                                    {
                                        string element_name = currButton.GetAttribute("Name");
                                        category_string = element_name.Substring(0, element_name.Length - suffix_length);
                                    }
                                }

                                item_info.Add(_keyList.k_store_app_category, category_string); //앱이 상세 범부("액션 및 어드벤쳐", "가족 및 어린이"와 같은 표현

                                System.Diagnostics.Debug.WriteLine(string.Format("item category name:{0}", category_string));
                            } //end of 범주

                            //Step3 : 평점 및 Review갯수
                            if (currString.Contains("평점"))
                            {
                                //This is abnormal case for element hierarchy. But, This is based on MS Naming Code
                                var result1 = Regex.Split(currString, ":"); // ":"을 기준으로 2개의 파트로 구분 한다.
                                                                            //첫번째 파트에서 숫자만 찾아서, 천단위 구분기호를 넣어준다.(store상에 표기되는 그대로 표시하기 위함)
                                string number_of_vote   = Regex.Replace(result1[0], @"\D", "");
                                int    vote_number      = int.Parse(number_of_vote);
                                string c_number_of_vote = String.Format("{0:#,###}", vote_number);
                                System.Diagnostics.Debug.WriteLine(string.Format("평가 갯수:{0}", c_number_of_vote));

                                item_info.Add(_keyList.k_store_app_review, c_number_of_vote);

                                //두번째 파트에서 실수를 찾는다. (4.0, 2.X와 같이 평점 표현)
                                Regex r = new Regex(@"[0-9]+\.[0-9]+");
                                Match m = r.Match(result1[1]);
                                System.Diagnostics.Debug.WriteLine(string.Format("평점:{0}", m.ToString()));

                                item_info.Add(_keyList.k_store_app_grade, m.ToString());
                                //foreach (var z1 in result1)
                                //{
                                //    System.Diagnostics.Debug.WriteLine(string.Format("part name:{0}", z1));
                                //    string strTmp = Regex.Replace(z1, @"\D", "");
                                //    System.Diagnostics.Debug.WriteLine(string.Format("replace name:{0}", strTmp));
                                //}
                                //_store_list.Add();
                            }
                        } //end of if(string null check)
                    }     //end of inner loop


                    //TOAN : 04/22/2020. inner for-loop에서 "범주"를 찾지 못한 경우.
                    //"개요" 영역에서 범주 값을 가지고 오기 위해, 다시한번 query수행.
                    if (String.IsNullOrEmpty(category_string))
                    {
                        var category_elements = _deskTopSession.FindElementsByXPath("//Group[@AutomationId=\"범주-toggle-target\"]//child::*");
                        category_string = category_elements[1].GetAttribute("Name").ToString();
                        item_info.Add(_keyList.k_store_app_category, category_string);
                    }

                    //취합된 정보를 list에 insert
                    //_store_list.Add(item_info);


                    var elementBack = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(ByAccessibilityId.AccessibilityId("NavigationViewBackButton")));
                    elementBack.Click();

                    //Thread.Sleep(2000);
                    //Thread.Sleep(/*5000*/8000);
                    //TO DO : Add Dictionary to List

                    //1번만 하고 종료 시킬려고 break문 사용(test용도)
                    //break;
                    System.Diagnostics.Debug.WriteLine(string.Format("Loop Counter:{0}", loop_counter));

                    //loop_counter = loop_counter + 1;
                    System.Diagnostics.Debug.WriteLine(string.Format("Data Fetch Logic End:{0}", _myUtility.getCurrentTime()));

                    //TOAN : 04/19/2020. Game Ranking의 경우. 30개 항목만 구한다.
                    //if (loop_counter > 30)
                    //if (loop_counter > 4)
                    //{
                    //    //TOAN : 04/22/2020. Debugging for Form1
                    //    _uiManager.HeyConnect();
                    //    break;
                    //}
                    //else
                    //{
                    //  _store_test_list.Add(item_info);
                    //}

                    _store_test_list.Add(item_info);
                } //end of element search



                ////Thread.Sleep(5000);
                //var gameElement = _deskTopSession.FindElementsByClassName("GridViewItem");
                //    var currList = gameElement.ToList();
                //    System.Diagnostics.Debug.WriteLine(string.Format("[Setting MenuList]List Count:{0}", currList.Count));

                ////compose dictionary info
                ////string categoryName = this.cboCategory.SelectedItem.ToString();
                ////string subclassName = this.cboSubclass.SelectedItem.ToString();

                //int loop_counter = 0;

                //TOAN : 04/22/2020. Debugging for Form1. below is ok
                //_uiManager.HeyConnect();

                //Below is data fetch logic
                //foreach (var currItem in currList)
                //{
                //    if(loop_counter>=10)
                //    {
                //        break; //exit internal loop for testing
                //    }
                //    loop_counter = loop_counter + 1;

                //    System.Diagnostics.Debug.WriteLine(string.Format("Data Fetch Logic Start:{0}", _myUtility.getCurrentTime()));

                //    Dictionary<string, object> item_info = new Dictionary<string, object>();  //해당 아이템의 필요한 정보를 뽑아서 사전 형태로 저장

                //    item_info.Add(_keyList.k_store_category, _categoryName);
                //    item_info.Add(_keyList.k_store_subclass, _subclassName);
                //    //Add Category and Subclass

                //    //System.Diagnostics.Debug.WriteLine(string.Format("element name:{0}", currItem.GetAttribute("Name")));
                //    //System.Diagnostics.Debug.WriteLine(string.Format("loop counter:{0}", loop_counter));
                //    //System.Diagnostics.Debug.WriteLine(string.Format("Offscreen value:{0}", currItem.GetAttribute("IsOffScrren")));
                //    //this.getTarget_Attributes(currItem);
                //    //Assert.isTrue

                //    //Thread.Sleep(/*5000*/8000);
                //    //TOAN : 04/16/2020. AutomatinID기준으로 item을 찾고 난 후 click진행(for loop반복시 이렇게 하지 않으면 exception발생)
                //    string itemID = currItem.GetAttribute("AutomationId");
                //    System.Diagnostics.Debug.WriteLine(string.Format("Automation ID:{0}", itemID));
                //    var currTarget = _deskTopSession.FindElementByAccessibilityId(itemID);
                //    //currTarget이 유효한지 확인 해보자(미니언즈)
                //    System.Diagnostics.Debug.WriteLine(string.Format("Current Element ID:{0}", currTarget));
                //    currTarget.Click();



                //    //Thread.Sleep(2000); //이게 답이 될까? 안되면 Explicit wait를 사용하자.
                //    //currItem.Click(); //해당 Item의 상세 정보 보기로 진입 한다.

                //    //get 1 depth목록
                //    //Thread.Sleep(3000);

                //    //var elements = _deskTopSession.FindElementsByXPath("//Button[@Name=\"NavigationControl\"]/child::*");
                //    //var elements = _deskTopSession.FindElementsByXPath("//Group[@AutomationId=\"pdp\"]//child::*");       //This is OK
                //    //var elements = _deskTopSession.FindElementByAccessibilityId("pdp").FindElementsByXPath("//*");      //This is OK
                //    //var elements = _deskTopSession.FindElementByAccessibilityId("pdp").FindElementsByXPath("//child::*"); //This is OK

                //    //step1 : get App Title
                //    System.Diagnostics.Debug.WriteLine(string.Format("DynamicHeading_productTitle Element Find Start:{0}", _myUtility.getCurrentTime()));
                //    var element = _deskTopSession.FindElementByAccessibilityId("DynamicHeading_productTitle");
                //    string itemName = element.GetAttribute("Name");

                //    item_info.Add(_keyList.k_store_app_name, itemName.ToString());

                //    //var elements = element.FindElementsByXPath("/following-sibling::*");
                //    //var elements = _deskTopSession.FindElementsByXPath("//Text[@AutomationId=\"DynamicHeading_productTitle\"]/following-sibling::*"); //This is OK

                //    //click한 이후에 형제 element들을 가지고 온다.
                //    System.Diagnostics.Debug.WriteLine(string.Format("[형제]DynamicHeading_productTitle Sibling Find Start:{0}", _myUtility.getCurrentTime()));
                //    var elements = _deskTopSession.FindElementsByXPath("//Text[@AutomationId=\"DynamicHeading_productTitle\"]//following-sibling::*"); //This is OK


                //    //TOAN : 04/22/2020. 하위 element에 범주 자체가 없는 경우도 발생
                //    //이경우는 개요 항목에서 "범주"를 다시 가지고 온다.
                //    //category_string변수 위치 변경.
                //    string category_string = "";

                //    foreach (var currElement in elements)
                //    {
                //        // System.Diagnostics.Debug.WriteLine(string.Format("child name:{0}", currElement.GetAttribute("Name"))); //print all sibling member
                //        //Step1 : Get Publisher
                //        string currString = currElement.GetAttribute("Name");
                //        System.Diagnostics.Debug.WriteLine(string.Format("current element name:{0}", currString));


                //        if (!String.IsNullOrEmpty(currString))
                //        {

                //            if (currString.Equals("게시자"))
                //            {
                //                var childElement = currElement.FindElementByXPath("//child::Button"); //Get first button element
                //                string publisher_name = childElement.GetAttribute("Name");
                //                System.Diagnostics.Debug.WriteLine(string.Format("publisher name:{0}", childElement.GetAttribute("Name"))); //print all sibling member
                //                item_info.Add(_keyList.k_sotre_app_manufacture, publisher_name);

                //            }
                //            //Step2 : Get Category
                //            if (currString.Equals("범주"))
                //            {

                //                var childElements = currElement.FindElementsByXPath("//child::Button"); //Get All button elements
                //                //string category_string = "";
                //                category_string = "";
                //                string suffix_string = "의 자세한 결과 보기";
                //                int suffix_length = suffix_string.Length; //범주에 "의 자세한 결과 보기"가 붙기 때문에, 해당 Title제거

                //                //Store의 범주는 눈에 보여지는 string과 ui element가 가지고 있는 형태가 틀리다.
                //                //예를 들어 Roblox의 경우 엑션 및 어드벤처,가족 및 어린이와 같이 표시되나.
                //                //내부적으로는
                //                //"액션 및 어드벤처의 자세한 결과 보기", "," ,"가족 및 어린이의 자세한 결과 보기"로 구성
                //                //즉, 접미사 형태로 "자세한 결과 보기"가 포함되어 있다. 따라서 이것에 대해 substring작업을 통해 별도 처리 한다.
                //                //위 작업은 suffix length와 substring을 통해 이루어 진다.


                //                foreach (var currButton in childElements)
                //                {
                //                    //category_string = String.Right()
                //                    if (!String.IsNullOrEmpty(category_string))
                //                    {
                //                        string element_name = currButton.GetAttribute("Name");
                //                        category_string = category_string + "," + element_name.Substring(0, element_name.Length - suffix_length);
                //                    }
                //                    else
                //                    {
                //                        string element_name = currButton.GetAttribute("Name");
                //                        category_string = element_name.Substring(0, element_name.Length - suffix_length);
                //                    }


                //                }

                //                item_info.Add(_keyList.k_store_app_category, category_string); //앱이 상세 범부("액션 및 어드벤쳐", "가족 및 어린이"와 같은 표현

                //                System.Diagnostics.Debug.WriteLine(string.Format("item category name:{0}", category_string));
                //            } //end of 범주

                //            //Step3 : 평점 및 Review갯수
                //            if (currString.Contains("평점"))
                //            {
                //                //This is abnormal case for element hierarchy. But, This is based on MS Naming Code
                //                var result1 = Regex.Split(currString, ":"); // ":"을 기준으로 2개의 파트로 구분 한다.
                //                                                            //첫번째 파트에서 숫자만 찾아서, 천단위 구분기호를 넣어준다.(store상에 표기되는 그대로 표시하기 위함)
                //                string number_of_vote = Regex.Replace(result1[0], @"\D", "");
                //                int vote_number = int.Parse(number_of_vote);
                //                string c_number_of_vote = String.Format("{0:#,###}", vote_number);
                //                System.Diagnostics.Debug.WriteLine(string.Format("평가 갯수:{0}", c_number_of_vote));

                //                item_info.Add(_keyList.k_store_app_review, c_number_of_vote);

                //                //두번째 파트에서 실수를 찾는다. (4.0, 2.X와 같이 평점 표현)
                //                Regex r = new Regex(@"[0-9]+\.[0-9]+");
                //                Match m = r.Match(result1[1]);
                //                System.Diagnostics.Debug.WriteLine(string.Format("평점:{0}", m.ToString()));

                //                item_info.Add(_keyList.k_store_app_grade, m.ToString());
                //                //foreach (var z1 in result1)
                //                //{
                //                //    System.Diagnostics.Debug.WriteLine(string.Format("part name:{0}", z1));
                //                //    string strTmp = Regex.Replace(z1, @"\D", "");
                //                //    System.Diagnostics.Debug.WriteLine(string.Format("replace name:{0}", strTmp));
                //                //}
                //                //_store_list.Add();
                //            }



                //        } //end of if(string null check)

                //    } //end of inner loop


                //    //TOAN : 04/22/2020. inner for-loop에서 "범주"를 찾지 못한 경우.
                //    //"개요" 영역에서 범주 값을 가지고 오기 위해, 다시한번 query수행.
                //    if (String.IsNullOrEmpty(category_string))
                //    {
                //        var category_elements = _deskTopSession.FindElementsByXPath("//Group[@AutomationId=\"범주-toggle-target\"]//child::*");
                //        category_string = category_elements[1].GetAttribute("Name").ToString();
                //        item_info.Add(_keyList.k_store_app_category, category_string);
                //    }

                //    //취합된 정보를 list에 insert
                //    //_store_list.Add(item_info);

                //    //다시 이전 gridview로 전환
                //    var elementBack = _deskTopSession.FindElementByAccessibilityId("NavigationViewBackButton");
                //    elementBack.Click();
                //    //Thread.Sleep(2000);
                //    //Thread.Sleep(/*5000*/8000);
                //    //TO DO : Add Dictionary to List

                //    //1번만 하고 종료 시킬려고 break문 사용(test용도)
                //    //break;
                //    System.Diagnostics.Debug.WriteLine(string.Format("Loop Counter:{0}", loop_counter));

                //    //loop_counter = loop_counter + 1;
                //    System.Diagnostics.Debug.WriteLine(string.Format("Data Fetch Logic End:{0}", _myUtility.getCurrentTime()));

                //    //TOAN : 04/19/2020. Game Ranking의 경우. 30개 항목만 구한다.
                //    //if (loop_counter > 30)
                //    //if (loop_counter > 4)
                //    //{
                //    //    //TOAN : 04/22/2020. Debugging for Form1
                //    //    _uiManager.HeyConnect();
                //    //    break;
                //    //}
                //    //else
                //    //{
                //    //  _store_test_list.Add(item_info);
                //    //}

                //    _store_test_list.Add(item_info);
                //} //end of element search
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Full Stacktrace: {0}", ex.ToString()));
                System.Diagnostics.Debug.WriteLine(string.Format("Exception Occurred Time:{0}", _myUtility.getCurrentTime()));
            }
            finally
            {
            }



            //최종 취합된 _store_test_list출력(30개만 출력하자)
            int lpCount = 1;

            foreach (var currTc in _store_test_list)
            {
                foreach (var currObj in currTc)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("Count:{0}, Key:{1}, Value:{2}", lpCount, currObj.Key, currObj.Value));
                    //System.Diagnostics.Debug.WriteLine("key:{0}, value:{1}", currObj.Key, currObj.Value);
                    lpCount = lpCount + 1;
                }
            }

            //UI Update for View
            //_uiManager.TestResultToListView(_store_test_list);


            //이제 취합 내용을 ListView로 업데이트 한다.
        }
        private IWebElement GetElement(string id)
        {
            IWebElement element = null;

            string[] index = null;
            if (id.Contains('[') && id.Contains(']'))
            {
                string[] idParts = id.Split(new[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
                id    = idParts[0];
                index = idParts.Skip(1).ToArray();
            }
            string signature = GetSignature(id);

            string[] byParams = new string[2];
            int      pos      = signature.IndexOf(':');

            byParams[0] = signature.Substring(0, pos);
            byParams[1] = signature.Substring(pos + 1);

            //Get all contexts of the driver,try to locate the elemnt in different context;
            IList <string> driverContexts = _driver.Contexts;


            int triedTimes = 0;

            foreach (string context in driverContexts)
            {
                triedTimes++;
                _driver.Context = context;
                //_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
                _javaScript = (IJavaScriptExecutor)_driver;


                try
                {
                    #region js, but not implement rightnow for android in appium
                    if (byParams[0].Equals("js", StringComparison.CurrentCultureIgnoreCase))
                    {
                        //1. try to get element by js directly
                        object elementObj = _javaScript.ExecuteScript(byParams[1]);

                        if (elementObj == null)
                        {
                            //2. try to return element by js
                            elementObj = _javaScript.ExecuteScript("return " + byParams[1]);
                        }
                        if (elementObj == null)
                        {
                            //3. try to get element from collections by js
                            string indexString = "[" + string.Join("][", index) + "]";
                            if (byParams[1].Contains("return"))
                            {
                                elementObj = _javaScript.ExecuteScript(string.Format("{0}{1};", byParams[1], indexString));
                            }
                            else
                            {
                                elementObj = _javaScript.ExecuteScript(string.Format("return {0}{1};", byParams[1], indexString));
                            }
                        }
                        if (elementObj == null)
                        {
                            throw new Exception(string.Format("Cannot found element {0}", id));
                        }

                        //if target is a collections, to get the one matched index
                        if (elementObj is System.Collections.IList)
                        {
                            elementObj = index.Aggregate(elementObj, (current, i) => ((System.Collections.IList)current)[int.Parse(i)]);
                        }

                        if (elementObj is IWebElement)
                        {
                            element = elementObj as IWebElement;
                        }
                        //else
                        //    element = new TextWebElement(elementObj.ToString());
                    }
                    #endregion
                    //other locate function but javascript.
                    else
                    {
                        By by = null;
                        if (byParams[0].Equals("AccessibilityId", StringComparison.CurrentCultureIgnoreCase))
                        {
                            by = new ByAccessibilityId(byParams[1].ToString());
                        }
                        else
                        {
                            by =
                                typeof(By).InvokeMember(byParams[0],
                                                        BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, null,
                                                        new object[] { byParams[1] }) as By;
                        }

                        if (index != null)
                        {
                            bool optionIsIndex = false;
                            int  optionIndex   = -1;
                            optionIsIndex = int.TryParse(index[0], out optionIndex);
                            if (!optionIsIndex)
                            {
                                if (index[0].StartsWith("\"") && index[0].EndsWith("\""))
                                {
                                    index[0] = index[0].Substring(1, index[0].Length - 2);
                                }
                            }
                            IList <IWebElement> foundList = _driver.FindElements(by);
                            //check the found element is list view
                            if (foundList.Count == 1 && foundList[0].TagName.ToLower().Contains("listview"))
                            {
                                IWebElement e           = foundList[0];
                                string      tagname     = e.TagName;
                                string      resource_id = e.GetAttribute("resourceId");
                                string      xpath       = string.Empty;
                                //if option is index, just search child, otherwise descendant.
                                if (optionIsIndex)
                                {
                                    xpath = string.Format("//{0}[@resource-id='{1}']/child::*", tagname, resource_id);
                                }
                                else
                                {
                                    xpath = string.Format("//{0}[@resource-id='{1}']/descendant::*", tagname, resource_id);
                                }
                                //get all children of the listview
                                IList <IWebElement> childElementList = _driver.FindElements(By.XPath(xpath));
                                if (childElementList.Count == 0)
                                {
                                    throw new OpenQA.Selenium.NoSuchElementException("There is not options for the element: " + id);
                                }
                                if (optionIndex >= childElementList.Count)
                                {
                                    throw new OpenQA.Selenium.NoSuchElementException("There is not option " + optionIndex + " in the element: " + id);
                                }
                                //check the option is index or content.
                                if (optionIsIndex)
                                {
                                    element = childElementList[optionIndex];
                                }
                                else
                                {
                                    element = childElementList.First(item => CommonHelper.IsMatchRegex(index[0], item.Text));
                                }
                                if (element == null)
                                {
                                    throw new OpenQA.Selenium.NoSuchElementException("There is not option " + index[0] + " in the element: " + id);
                                }
                            }
                            //if the result is collection, just get the item in the collection
                            else
                            {
                                //check the option is index or content.
                                if (optionIsIndex)
                                {
                                    element = foundList[optionIndex];
                                }
                                else
                                {
                                    element = foundList.First(item => CommonHelper.IsMatchRegex(index[0], item.Text));
                                }
                            }
                        }
                        //if there is [#], will return the element directly.
                        else
                        {
                            element = _driver.FindElement(by);
                        }
                    }
                }
                catch
                {
                    if (triedTimes == driverContexts.Count)
                    {
                        throw new Exception(string.Format("Cannot found element {0}", id));
                    }
                }

                //If found the element in one context, quit the foreach
                if (element != null)
                {
                    break;
                }
            }
            return(element);
        }