public void SaveAsCopyAndRename() { // Upload a document SharepointClient.UploadFile(Excel); // Refresh web address Browser.Goto(Browser.BaseAddress); // Find and open document Browser.Wait(By.CssSelector("a[href*='" + filename + ".xlsx']")); var Docment = Browser.webDriver.FindElement(By.CssSelector("a[href*='" + filename + ".xlsx']")); Browser.Click(Docment); // Find and click "Edit WorkBook" tab var editExcel = Browser.FindElement(By.XPath("//a[@id='m_excelWebRenderer_ewaCtl_flyoutExcelEdit-Medium20']"), false); editExcel.SendKeys(OpenQA.Selenium.Keys.Enter); //SendKeys.SendWait("Enter"); // Find and click "Edit in Browser" tab var editInbrowser = Browser.webDriver.FindElement(By.XPath("//a[@id = 'm_excelWebRenderer_ewaCtl_btnEditInWebApp-Menu32']")); editInbrowser.SendKeys(OpenQA.Selenium.Keys.Enter); //SendKeys.SendWait("Enter"); // Click the title of the online excel and renamed it by add "new" var rename = Browser.webDriver.FindElement(By.XPath("//div[@id='BreadcrumbTitle']")); (Browser.webDriver as IJavaScriptExecutor).ExecuteScript("arguments[0].innerHTML = arguments[1];", rename, "new" + rename.Text + "\r"); Actions action = new Actions(Browser.webDriver); action.Click(rename).Build().Perform(); rename.SendKeys(OpenQA.Selenium.Keys.Enter); Thread.Sleep(8000); // Renamed it back to the original name (Browser.webDriver as IJavaScriptExecutor).ExecuteScript("arguments[0].innerHTML = arguments[1];", rename, rename.Text.Substring(3) + "\r"); action.Click(rename).Build().Perform(); rename.SendKeys(OpenQA.Selenium.Keys.Enter); Thread.Sleep(8000); // Back to base address Browser.Goto(Browser.BaseAddress); Thread.Sleep(3000); Docment = Browser.webDriver.FindElement(By.CssSelector("a[href*='" + filename + ".xlsx']")); Browser.Click(Docment); // Find and click tab ... var elementInframe = Browser.FindElement(By.XPath("//a[@id='m_excelWebRenderer_ewaCtl_ExcelViewerHeroDockOverflowMenuLauncher-Small20']"), false); elementInframe.SendKeys(OpenQA.Selenium.Keys.Enter); //SendKeys.SendWait("Enter"); // Find and click SaveAsCopy tab var saveacopy = Browser.webDriver.FindElement(By.XPath("//a[@id='m_excelWebRenderer_ewaCtl_Jewel.SaveACopy-Menu20']")); saveacopy.SendKeys(OpenQA.Selenium.Keys.Enter); //SendKeys.SendWait("Enter"); // Input a name for the new copy document var saveAs = Browser.webDriver.FindElement(By.XPath("//input[@id='workbookName']")); saveAs.SendKeys("Copy" + saveAs.Text); // Click save button var save = Browser.webDriver.FindElement(By.XPath("//button[@type='submit']")); save.SendKeys(OpenQA.Selenium.Keys.Enter); Thread.Sleep(8000); // Back to base address Browser.Goto(Browser.BaseAddress); // Delete the new created copy document SharepointClient.DeleteFile("Copy" + filename + ".xlsx"); // Delete the new upload document SharepointClient.DeleteFile(filename + ".xlsx"); StopTrace(); bool parsingResult = MessageParser.ParseMessageUsingWOPIInspector(captureName); Assert.IsTrue(parsingResult, "Case failed, check the details information in error.txt file."); }
public void CoautherWithConflict() { // Upload a document SharepointClient.UploadFile(Word); // Refresh web address Browser.Goto(Browser.BaseAddress); // Find document on site IWebElement document = Browser.webDriver.FindElement(By.CssSelector("a[href*='" + filename + ".docx']")); // Open document by office word Browser.RClick(document); var elementOpenInWord = Browser.webDriver.FindElement(By.XPath("//div[@id='ID_EditIn_Word']")); Browser.Click(elementOpenInWord); // Close microsoft office dialog and access using expected account Utility.CloseMicrosoftOfficeDialog(); string username = ConfigurationManager.AppSettings["OtherUserName"]; string password = ConfigurationManager.AppSettings["OtherPassword"]; Utility.OfficeSignIn(username, password); // Wait for document is opened Utility.WaitForDocumentOpenning(filename); // Get the opened word process, and edit it Word.Application wordToOpen = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application"); Word.Document oDocument = (Word.Document)wordToOpen.ActiveDocument; oDocument.Content.InsertBefore("HelloWordConfilict"); // Double click the document in root site Browser.Click(document); // Find and click "Edit Document" tab var editWord = Browser.FindElement(By.XPath("//a[@id='flyoutWordViewerEdit-Medium20']"), false); editWord.SendKeys(OpenQA.Selenium.Keys.Enter); SendKeys.SendWait("Enter"); // Find and click "Edit in Browser" tab var editInbrowser = Browser.webDriver.FindElement(By.XPath("//a[@id ='btnFlyoutEditOnWeb-Menu32']")); editInbrowser.SendKeys(OpenQA.Selenium.Keys.Enter); SendKeys.SendWait("Enter"); // Wait for document is opened var saved = Browser.FindElement(By.XPath("//span[@id='BreadcrumbSaveStatus'][text()='Saved']"), false); // Edit it in online SendKeys.SendWait("HelloOfficeOnlineConflict"); // Wait for online edit saved saved = Browser.FindElement(By.XPath("//span[@id='BreadcrumbSaveStatus'][text()='Saved']"), false); Thread.Sleep(60000); // Refresh web address Browser.Goto(Browser.BaseAddress); // Save it in office word and close and release word process Utility.WordEditSave(filename); Thread.Sleep(10000); Utility.CloseMicrosoftWordDialog(filename, "OK"); Utility.WordConflictMerge(filename); oDocument.Close(); Utility.DeleteDefaultWordFormat(); Marshal.ReleaseComObject(oDocument); Marshal.ReleaseComObject(wordToOpen); // Delete the new upload document SharepointClient.DeleteFile(filename + ".docx"); bool result = FormatConvert.SaveSAZ(TestBase.testResultPath, testName, out file); Assert.IsTrue(result, "The saz file should be saved successfully."); bool parsingResult = MessageParser.ParseMessageUsingWOPIInspector(file); Assert.IsTrue(parsingResult, "Case failed, check the details information in error.txt file."); }
public void CoautherWithoutConflict() { // Upload a document SharepointClient.UploadFile(Word); // Refresh web address Browser.Goto(Browser.DocumentAddress); // Find document on site IWebElement document = Browser.webDriver.FindElement(By.CssSelector("a[href*='" + wordFilename + ".docx']")); // Open document by office word Browser.RClick(document); Browser.Wait(By.LinkText("Open in Word")); var elementOpenInWord = Browser.webDriver.FindElement(By.LinkText("Open in Word")); Browser.Click(elementOpenInWord); // Close Microsoft office dialog and access using expected account Utility.WaitForDocumentOpenning(wordFilename, false, true); string username = ConfigurationManager.AppSettings["UserName"]; string password = ConfigurationManager.AppSettings["Password"]; bool isWindowsSecurityPop = Utility.WaitForDocumentOpenning(wordFilename, false, true); if (isWindowsSecurityPop) { Utility.OfficeSignIn(username, password); Thread.Sleep(1000); Utility.OfficeSignIn(username, password); } // Wait for document is opened Utility.WaitForDocumentOpenning(wordFilename); // Get the opened word process, and edit it Word.Application wordToOpen = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application"); Word.Document oDocument = (Word.Document)wordToOpen.ActiveDocument; oDocument.Content.InsertAfter("HelloWord"); // Double click the document in root site Browser.Click(document); Browser.Wait(By.Id("WebApplicationFrame")); Browser.webDriver.SwitchTo().Frame("WebApplicationFrame"); Thread.Sleep(3000); // Find and click "Edit Document" tab var editWord = Browser.FindElement(By.XPath("//a[@id='flyoutWordViewerEdit-Medium20']"), false); editWord.Click(); // Find and click "Edit in Browser" tab Browser.Wait(By.Id("btnFlyoutEditOnWeb-Menu32")); var editInbrowser = Browser.webDriver.FindElement(By.XPath("//a[@id ='btnFlyoutEditOnWeb-Menu32']")); editInbrowser.Click(); // Wait for document is opened Browser.Wait(By.XPath("//span[@id='BreadcrumbSaveStatus'][text()='Saved']")); oDocument.Save(); oDocument.Close(); Utility.DeleteDefaultWordFormat(); Marshal.ReleaseComObject(oDocument); Marshal.ReleaseComObject(wordToOpen); // Refresh web address Browser.Goto(Browser.BaseAddress); // Delete the new upload document SharepointClient.DeleteFile(wordFilename + ".docx"); bool result = FormatConvert.SaveSAZ(testResultPath, testName, out file); Assert.IsTrue(result, "The saz file should be saved successfully."); bool parsingResult = MessageParser.ParseMessageUsingWOPIInspector(file); Assert.IsTrue(parsingResult, "Case failed, check the details information in error.txt file."); }