public void Exclusivelock() { // 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']")); // Checkout the document SharepointClient.LockItem(wordFilename + ".docx"); // Open it in 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); // Sign in Word App. 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(2000); Utility.OfficeSignIn(username, password); } // Wait for document is opened Utility.WaitForDocumentOpenning(wordFilename); // Update the document content Word.Application wordToOpen = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application"); Word.Document oDocument = (Word.Document)wordToOpen.ActiveDocument; oDocument.Content.InsertBefore("Exclusivelock"); // Save and close and release word process oDocument.Save(); oDocument.Close(); Utility.DeleteDefaultWordFormat(); Marshal.ReleaseComObject(oDocument); Marshal.ReleaseComObject(wordToOpen); SharepointClient.UnLockItem(wordFilename + ".docx"); // Delete the new upload document SharepointClient.DeleteFile(wordFilename + ".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 SchemalockCheck() { // 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*='" + filename + ".docx']")); // Checked out it SharepointClient.LockItem(filename + ".docx"); // Open it by word Browser.RClick(document); Browser.Wait(By.LinkText("Open in Word")); var elementOpenInWord = Browser.webDriver.FindElement(By.LinkText("Open in Word")); Browser.Click(elementOpenInWord); Utility.CloseMicrosoftOfficeDialog(); Utility.WaitForDocumentOpenning(filename); // Sign in office word with another account and wait for it opening in readonly mode string username = ConfigurationManager.AppSettings["OtherUserName"]; string password = ConfigurationManager.AppSettings["OtherPassword"]; Utility.OfficeSignIn(username, password); Utility.OfficeSignIn(username, password); Utility.CloseFileInUsePane(filename); Utility.WaitForDocumentOpenning(filename, true); Word.Application wordToOpen = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application"); Word.Document oDocument = (Word.Document)wordToOpen.ActiveDocument; // Wait for CheckLockAvailability Thread.Sleep(60000); Utility.CloseFileNowAvailable(filename); // Close and release word process oDocument.Close(); Utility.DeleteDefaultWordFormat(); Marshal.ReleaseComObject(oDocument); Marshal.ReleaseComObject(wordToOpen); SharepointClient.UnLockItem(filename + ".docx"); // 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 SchemalockToExclusivelock() { // 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 it in office word Browser.RClick(document); var elementOpenInWord = Browser.webDriver.FindElement(By.XPath("//div[@id='ID_EditIn_Word']")); Browser.Click(elementOpenInWord); Utility.CloseMicrosoftOfficeDialog(); // Sign in office word and wait for it opening string username = ConfigurationManager.AppSettings["UserName"]; string password = ConfigurationManager.AppSettings["Password"]; Utility.OfficeSignIn(username, password); Utility.WaitForDocumentOpenning(filename); // Update the document content Word.Application wordToOpen = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application"); Word.Document oDocument = (Word.Document)wordToOpen.ActiveDocument; oDocument.Content.InsertBefore("SchemalockToExclusivelock"); // Save and close and release word process oDocument.Save(); Utility.CheckOutOnOpeningWord(filename); oDocument.Close(); Utility.DeleteDefaultWordFormat(); Marshal.ReleaseComObject(oDocument); Marshal.ReleaseComObject(wordToOpen); SharepointClient.UnLockItem(filename + ".docx"); // 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."); }