2

Our site has a good number of reports that are using SSRS,Crystal and Excel. We are using C# with Selenium WebDriver. I have been searching for the best practices and best ways and tools to test the content of those report. I need to test pdf/excel content or both depending on the report I am testing. I know Selenium does not have native support for this kind of testing. My question is what kind of tool I can integrate with Selenium to accomplish that. Open source preferred.

In summary:

  1. How to test pdf/excel content with C#?
  2. What are the best practice?
3

I think I can point you in the right direction for MS Word, at least.

You can use the Office Interop Assemblies in C#.

Here is an example from .Net Pearls:

using System;
using Microsoft.Office.Interop.Word;

class Program
{
    static void Main()
    {
    // Open a doc file.
    Application application = new Application();
    Document document = application.Documents.Open("C:\\word.doc");

    // Loop through all words in the document.
    int count = document.Words.Count;
    for (int i = 1; i <= count; i++)
    {
        // Write the word.
        string text = document.Words[i].Text;
        Console.WriteLine("Word {0} = {1}", i, text);
    }
    // Close word.
    application.Quit();
    }
}
  • 1
    Thanks! That sounds promising. I will definitely look into – saifur Mar 12 '15 at 20:39
2

Webdriver is a browser manipulation API only and as such the ability to read office or PDF files is out of scope of its capabilities, but the office interop libraries will allow you to read data from office files in C#, and there will be similar libraries for reading PDF documents.

  • Thanks for your response. I know that and I mentioned that in my question. I was looking for the libraries available to accomplish that. – saifur Mar 30 '15 at 22:35
  • No worries like I mentioned, the office interop libraries should be fine for reading office files, and I have heard good things about the PdfSharp.Net library for inspecting PDF files. Hope that helps – chrisc Mar 30 '15 at 22:38
  • Will check this out – saifur Mar 30 '15 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.