3

I am new to selenium and I am using selenium to do the testing but I am confused right now.

For example, the website I am working on contains lots of data, however all of them are from database. Users need to click some buttons or select values from drop down list, then the front-end with send request with these parameters. Database will return different values due to different parameters. After front-end receives these values, front-end will process them to graphs or show them directly.

I used selenium to complete the click or select parts, but how can I verify the data come from the database? use SQL with selenium code? But I heard that selenium should not do this. I thought about data-driven, but it seems the only part i can use is login part. Can someone tell my what kinds of things that selenium should test? Or in my case, selenium is not a good choice at all.

I am sorry. Although I know this question is too board, but I really need some advice.

  • You should not accept answer in just few hours, because many people from other timezones might be willing to give you opinion, but would not waste time if you already accepted an answer. – Peter M. Jun 7 '17 at 13:59
2

Selenium is software framework that is commonly used for webpage testing.

  • You can combine Selenium framework with other frameworks, in your case, DB testing frameworks.

But I heard that selenium should not do this.

  • You can carefully design your Selenium testing framework with DB testing framework that they will work together independently. Using Selenium framework with other testing framework is not a taboo.

What I can suggest:

  • Using data-driven test approach as you said.
  • Build a front end testing suite using Selenium, execute tests, read back graphical information, convert them if necessary and compare results against expected values from your test data.
  • With Selenium, you can also verify buttons are clickable, URLs are reachable and graphs are displayed.
  • Build a back end testing suite using a DB testing framework of your choice, execute tests and compare results against expected values from your test data.
  • Selenium test suite and DB test suite are built and executed independently, e.g. they are two separate test suites.

Scenario Walkthrough:

Say, you are testing a website that requires you to make a selection from a dropdown list and a graph is printed in return.

  • You can use Selenium to navigate to this URL, click on a dropdown list, make a selection, reads back the grapth displayed, converts it to a numerical value and compare it against your expected value from you test data.
  • Or, you can make a direct SQL query from your DB test suites to the DB server, compare the returned result against your expected value from your test data.

Front-end need to use the data from database. If the DB testing and Selenium test are built and executed independently,

  • How can selenium know the data sent from database?
  • If selenium cannot know the data, then how can selenium compare with the data showing in the graph and data received from database? Or should I use data driven test to do this part?

Say, below it is the website under test.

  • When the button is clicked, this webpage will fetch a whole bunch of numerical data from its database, convert numerical data into a graph and display it on the website.

System under test

After you take over, you have developed two test suites, one is Selenium test suite and another one is Database test suite.

  • You have created a data file that contains some pre-conditions and expected results. How you collected those data? You can achieve those data from playing with the website and / or making SQL query into the backend database.
  • Selenium test suite will click the button, read the generated graph, convert the bars on this graph back to numerical values and compare those numerical values against expected results. Selenium does not know how the graph is drawn or where the data come from; hence front end testing.
  • Database test suite will simply make direct SQL queries into the database; those SQL queries will fetch the same bunch of raw numerical data from the database; database test suite can then compare them against expected values from the test data file.
  • You may wonder what kind of SQL queries you need to pass onto the database server in order to fetch the same set of data, you may need to ask this webpage's developer in order to learn which SQL queries to use.

enter image description here

  • Thx for your reply. It really helps a lot. Just some more questions about the database testing suit u mentioned. As I posted, front-end need to use the data from database. If the DB testing and Selenium test are build and executed independently, How can selenium know the data sent from database? If selenium cannot know the data, then how can selenium compare with the data showing in the graph and data received from database? Or should I use data driven test to do this part? – Lehtia Jun 7 '17 at 1:35
  • @user2806237, give me a couple of hours, I will answer your questions with an example. – Yu Zhang Jun 7 '17 at 1:37
  • @YenanBai You can also use Selenium to ensure the webpage formatted the data correctly. So you have a special database to serve as known input that covers your test conditions. It's the same data every time, so you know your output. This makes sure your coders didn't mess up the logic used to create those outputs. – corsiKa Jun 7 '17 at 4:27
  • @YenanBai, updated my answer, any question, please do come back to me. – Yu Zhang Jun 7 '17 at 4:46
  • @YuZhang, Thanks a lot. I may know how I can work on creating my test suites. Meanwhile, currently, I am trying to use data-driven test. As I know the input and output. But When things change, the old data can be useless. I think use query to read data from database and then compare with local data is very smart. And the most important thing is I know how to use selenium correctly. Thx a lot for your help. – Lehtia Jun 7 '17 at 6:13

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.