- How do I open an excel file?
- How do I write test results to file?
- How do I run my test in Jenkins?
Beginners might search on Google, the term, "How do I open excel files in Selenium?", but what you'll find is your results might not match expectations or no results.
Let's try to understand the test ecosystem and architecture so you can better phrase your search queries next time you need to do something.
How it all fits together
In your Selenium WebDriver or RC test, you have these 3 main concepts.
- Your programming language - Your basic building block.
- Your test framework - The context of how your test runs and reports results, and execution of your test scripts/programs.
- Selenium Webdriver - The interface which your test scripts/programs use to access the browsers functions. More specifically, accessing web elements within the browser.
Asking your question
Now when you try to ask the question, you'll want to go through these backwards.
Let's take the example, "How do I read test data from an Excel file?".
Going through the steps, we ask ourselves the following questions..
- Are we interacting with a web element or browser at this point? - No. We don't need to search for a Selenium/WebDriver solution for this problem.
- Are we trying to interact with the test environment? - Yes, we need to feed data
- Is there something I'm trying to do that's not part of Selenium/WebDriver or the test framework. Possibly. We may need to figure out how to open the file.
Given that 2 and 3 are yes. You'll probably want to search along the lines of..
- How do I feed Excel data into (insert your test framework here)
- Reading Excel data into (insert your test framework here)
If that fails, you'll want to fall back to the language, and break the problem down into smaller pieces. Here we'll want to read the Excel file into some sort of data structure, then feed that data structure into the test framework.
- How do I open a Excel file in C#,Java, etc...
- How can I read an Excel file in ...
- How do I feed array data into (insert test framework here)
When you find yourself needing to find a solution. Remember to figure out where in your test architecture you need the solution at and break down the problem.