public void ATC9361_CRMRegisterDocumentIntoInvestigationCase()
        {
            User user = this.environment.GetUser(SecurityRole.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsCasesRibbonButton();

            InvestigationCaseSearchPage investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.ClickNewInvestigationCaseButton();
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            var investigationCase = investigationCasePage.GetInvestigationCaseNumber();

            homePage.HoverClientRibbonTab(investigationCase.ToUpperInvariant());
            Thread.Sleep(500);
            driver.FindElement(By.XPath("//a[@title='Documents' and @id='Node_navDocument']")).Click();

            var directoryName = UICommon.GetAlertMessage(driver).Split(new[]{"/"}, StringSplitOptions.RemoveEmptyEntries).Last();

            var baseWindow = driver.CurrentWindowHandle; //Records the current window handle
            var gridFrame = driver.SwitchTo().DefaultContent().SwitchTo().Frame("contentIFrame1").SwitchTo().Frame("areaDocumentFrame").SwitchTo().Frame("gridIframe");
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
            wait.Until(ExpectedConditions.ElementIsVisible(By.Id("mnuNewButton")));
            gridFrame.FindElement(By.Id("mnuNewButton")).Click();
            Thread.Sleep(1000);
            gridFrame.FindElement(By.XPath("//span[contains(text(), 'Investigation Case Document')]")).Click();
            Thread.Sleep(3000);
            SwitchWindow(baseWindow);

            var a = new Actions(driver);
            var fileUpload = driver.SwitchTo().Frame("spPageFrame").FindElement(By.Id("ctl00_PlaceHolderMain_UploadDocumentSection_ctl05_InputFile"));
            a.DoubleClick(fileUpload).Build().Perform();
            Thread.Sleep(2000);

            var myFile = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "inv_case_doc.txt");
            if (File.Exists(myFile)) File.Delete(myFile);
            var sw = new StreamWriter(myFile);
            sw.WriteLine("Hello world!");
            sw.Flush();
            sw.Close();

            var ai = new AutoItX3();
            var winTitle = "Choose File to Upload";
            int found = ai.WinWait(winTitle, "", Properties.Settings.Default.SHORT_WAIT_SECONDS);

            if (found == 1)
            {
                ai.WinActivate(winTitle);
                ai.Send(myFile);
                ai.Send("{ENTER}");
                ai.WinWaitClose(winTitle);
            }
            else
            {
                throw new Exception("Unable to locate open file dialog");
            }

            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
            wait.Until(ExpectedConditions.ElementIsVisible(By.Id("ctl00_PlaceHolderMain_ctl03_RptControls_btnOK")));
            driver.FindElement(By.Id("ctl00_PlaceHolderMain_ctl03_RptControls_btnOK")).Click();

            wait.Until(ExpectedConditions.ElementIsVisible(By.Id("Ribbon.DocLibListForm.Edit.Commit.Publish-Large")));
            driver.FindElement(By.Id("Ribbon.DocLibListForm.Edit.Commit.Publish-Large")).Click();

            gridFrame = driver.SwitchTo().DefaultContent().SwitchTo().Frame("contentIFrame1").SwitchTo().Frame("areaDocumentFrame").SwitchTo().Frame("gridIframe");
            var table = gridFrame.FindElement(By.XPath("//div[@id='divDataArea']/div/table"));

            // verify document is in the table
            if (!table.IsTextInTable("inv_case_doc.txt"))
                throw new Exception("Unable to locate file in CRM");

            gridFrame.FindElement(By.Id("openSharepointButton")).Click();
            Thread.Sleep(5000);
            SwitchWindow(baseWindow);

            var spTable = driver.FindElement(By.Id("onetidDoclibViewTbl0"));

            // verify document is in the table
            if (!spTable.IsTextInTable("inv_case_doc.txt"))
                throw new Exception("Unable to locate file in Sharepoint");

            driver = driver.SwitchTo().Window(baseWindow);
        }