Example #1
0
        public void ShareOnCreateCourse()
        {
            selenium.WaitForPageToLoad("40000");
            selenium.Click("link=Create New");
            selenium.WaitForPageToLoad("40000");
            selenium.Type("id=Name", "Test");
            selenium.WaitForPageToLoad("40000");

            //          selenium.Click("//p[2]");

            selenium.DoubleClick("//div/select/option");

            selenium.Click("css=input[value=\"Create\"]");
            selenium.WaitForPageToLoad("40000");

            bool isPresent = selenium.IsElementPresent("//table[@id='myCourses']//tr//td[contains(.,'Test')]");

            Assert.IsTrue(isPresent);
        }
        private void uploadFile(int i)
        {
            StartRC();
            i++;
            try
            {
                selenium.Open("/GEDA15/index.html");
                selenium.WaitForPageToLoad("50000");
                selenium.Type("username", "YQ_LI");
                selenium.Type("password", "Reuters5");
                //selenium.Click("ext-gen27");
                selenium.Click("//button[@class=' x-btn-text'][text()='Login']");
                selenium.WaitForPageToLoad("50000");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("css=img.x-tree-ec-icon.x-tree-elbow-end-plus");
                System.Threading.Thread.Sleep(2000);
                selenium.DoubleClick("//ul[@class='x-tree-node-ct']/li[@class='x-tree-node']/descendant::a[@class='x-tree-node-anchor']/span[text()='Message Editor']");
                selenium.SelectFrame("IFFMEditor");
                System.Threading.Thread.Sleep(4000);

                //Upload the first file
                selenium.Click("ext-gen163");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//div[@class='x-combo-list-inner']/descendant::div[contains(@class, 'x-combo-list-item')][text()='HK_BULK']");
                selenium.Click("ext-gen168");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("css=#ext-gen182 > div.x-combo-list-item");
                selenium.Click("//button[@class=' x-btn-text search'][text()='Search']");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//button[@class=' x-btn-text import'][text()='Upload File']");
                System.Threading.Thread.Sleep(2000);
                selenium.Type("form-file", "D:\\HKRicTemplate\\HKG_EQLB.txt");
                System.Threading.Thread.Sleep(3000);
                //Upload
                selenium.Click("//button[@class=' x-btn-text'][text()='Upload']");
                System.Threading.Thread.Sleep(2000);
                //Ok
                selenium.Click("//button[@class=' x-btn-text'][text()='OK']");
                System.Threading.Thread.Sleep(3000);

                //Upload the second file
                selenium.Click("ext-gen163");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//div[@class='x-combo-list-inner']/descendant::div[contains(@class, 'x-combo-list-item')][text()='HK_CBBC1']");
                selenium.Click("ext-gen168");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("css=#ext-gen182 > div.x-combo-list-item");
                selenium.Click("//button[@class=' x-btn-text search'][text()='Search']");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//button[@class=' x-btn-text import'][text()='Upload File']");
                System.Threading.Thread.Sleep(2000);
                selenium.Type("form-file", "D:\\HKRicTemplate\\HKG_EQLB_CBBC.txt");
                System.Threading.Thread.Sleep(2000);
                //Upload
                selenium.Click("//button[@class=' x-btn-text'][text()='Upload']");
                System.Threading.Thread.Sleep(2000);
                //Ok
                selenium.Click("//button[@class=' x-btn-text'][text()='OK']");
                System.Threading.Thread.Sleep(3000);

                //Upload the third file
                selenium.Click("ext-gen163");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//div[@class='x-combo-list-inner']/descendant::div[contains(@class, 'x-combo-list-item')][text()='HK_EQLBMI']");
                selenium.Click("ext-gen168");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("css=#ext-gen182 > div.x-combo-list-item");
                selenium.Click("//button[@class=' x-btn-text search'][text()='Search']");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//button[@class=' x-btn-text import'][text()='Upload File']");
                System.Threading.Thread.Sleep(2000);
                selenium.Type("form-file", "D:\\HKRicTemplate\\HKG_EQLBMI.txt");
                System.Threading.Thread.Sleep(2000);
                //Upload
                selenium.Click("//button[@class=' x-btn-text'][text()='Upload']");
                System.Threading.Thread.Sleep(2000);
                //Ok
                selenium.Click("//button[@class=' x-btn-text'][text()='OK']");

                selenium.Close();
                selenium.Stop();
            }
            catch (SeleniumException ex)
            {
                if (ex.Message.Contains("Timed out") && i < 4)
                {
                    uploadFile(i);
                }

                MessageBox.Show(ex.Message);
                selenium.Close();
                selenium.Stop();
            }
        }