2

I am just finish my selenium code. I'm following page object pattern. My code does not follow any frameworks. My senior who reviewed my code said that::

  1. You need to keep the test data separately. Not scattering all over the script.
    • Keep the test data in Json. And read it from there where ever it is necessary. Any secret key or password must be encrypted with any logic.
    • There are many code available for encryption. And readme file which tells about how to run the project.
  2. I think framework is not expandable. Like if you want to run the same test in multiple browsers there must be a configuration file.
  3. For login page: If you need to login with username and password, you should pass the password in encrypted format. While so you would need to save the password encrypted in test data. While sending password to that field you should decrypt and send that in selenium script.

Can anybody please clarify for me whether I should need to use any frameworks?

4 Answers 4

3

Centralize test-data:

I like to put test-data into Class objects and not in text-files. This way you can use proper code completion for your test-data. Centralizing test-data from "strings" is a must, you do not want to change hundreds of "strings" when changing test-data.

Encryption of test-data:

Encryption of test data should be a company policy, but adds extra complexity. If the test environment is not world reachable and the accounts are test specific, than personally I do not care for encryption. Most encryptions are reversible if you have the code, so you need a encryption framework that works on all your test-agents, but cannot be decrypted if someone steals the code. I would really wonder if you need this.

Better is to just generate test users on the fly for your test. This way you can use random passwords only for that tests. This removes the need to encrypt any data. A user class object could create the user on first usage. Preferable use the same user creating logic as the application uses. Then you can store the password only in memory :)

Cross-browser:

Extend when needed, use YAGNI and do not over complicate your framework if you do not plan to test on multiple browsers now. My current project is Chrome only. So we only test on Chrome. I am fine with refactoring the tests if we need to support another browser later. We might never reach that state so let's first get a market-fit for our internal reporting tool instead of focusing on supporting all browsers, probably we never will.

there must be a configuration file.

So there must only be a configuration file if you need it now! :) Developers have a hand of I know we will need this, because other projects.. bla bla bla. Don't make up requirements based on past knowledge, it is a possible waste and I cannot repeat this often enough.

If you do need to test on multiple browsers as a requirement, start with adding one in a early stage of your framework and try to make it flexible. Code it in such a way you can inject another a browser later if needed. For example with an parameter from the command-line or a config file. Your tests should not be browser aware, so no IF CHROME blocks.

Documentation:

Yes, you do need basic documentation how to install, run and usage your tests. Seems logical. You make software for other humans not computers.

3
  • I'm following page object pattern so Why should we use frameworks ?
    – user21268
    Commented Dec 16, 2016 at 11:04
  • Page Objects is no framework, it is a test design pattern. Your code-review feedback is also about practises and patterns. Not about solutions in a framework. Your combination of tools, used frameworks, patterns and practises could be called "Your test framework", but I would rather call it implementation. Selenium is a framework as it has a clear way to use it for a specific use-case. It is a "a basic structure underlying a system". Commented Dec 16, 2016 at 11:09
  • With this information could you ask your question again, because I have no idea what you mean with "Why should we use frameworks?". My answer would be, because it delivers basic structure and in your case the PageObject pattern does not deliver all the basic structure needed. Commented Dec 16, 2016 at 11:12
1

To expand on some of the other points:

Test Data

Test data should be separate from the rest of the automation code. The reason is this: if you do not separate your test data, as you add new tests you will duplicate field identifiers and the data to enter. When there is a change to the code, you will have a maintenance nightmare.

Also, if your test data is in a separate, non-compiled format, it's a lot easier for other people to add new tests. If the data format for each type of test is clearly defined, all that's needed to add an iteration of a test is to edit a text file and add a new row of data.

Encryption

If you are using real logins as opposed to users who exist only for test purposes, then yes, you do need to use encryption. If your test code is accessible outside your intranet, you should be encrypting your data access, passwords, and any other data that could be used by a hostile entity to attack your company systems.

Framework Expandability

By writing a set of automated tests, you have created your own framework. It needs to be expandable so that you can:

  • point it at different server instances of the web application
  • run it in parallel as it grows
  • run specific tests - as your test suite grows, it will become less viable to run the entire thing with each build (if this was ever viable to start with). Refactoring to have a config file and external data sets means you can define a set of smoke tests to run each build, and have longer test suites running on a scheduled basis.
1

Framework is must if any company is planning to adapt Automation (More Specifically for Selenium Web driver).

Let me try to clarify what are the perspective for this points.

Point 1 : You need to keep the test data separately. Not scattering all over the script.

  • Just do not write test script anywhere. Create module wise class. Do not write @test anywhere also.

  • If you follow above point , test data will not me scattered everywhere. You will also get proper place to write test data,

  • Use file for giving test data is possible.

  • Click here for more information

Point 2 : Keep the test data in JSON. And read it from there where ever

  • As I had mention in Point 1 use file to read data.

Point 3 : it is necessary. Any secret key or password must be encrypted with any logic.

  • Security is the most important thing. Password should be in encrypted form. But there is also call of your organization. If they are happy to give you permission to use password without encryption then use it.

Point 4 : I think framework is not expandable

  • This something related to configuration. So here the same as Point 1.

  • Use configuration file like property file. Here you can mentioned browser name and concurrent run or not etc.

  • You can use testng.xml Click Here

Point 5 : Send password in decrypted form

  • As Point 3 follow standard.

Please let me know If you need more clarification.

4
  • My question is I'm following page object model. Is there any framework needed in page object ?
    – user21268
    Commented Dec 16, 2016 at 10:25
  • Point 1 is not getting. please tell an example to understand
    – user21268
    Commented Dec 16, 2016 at 10:31
  • Point 1 is about making framework. So It can easily use your test data
    – Sagar007
    Commented Dec 16, 2016 at 12:39
  • If you are following page object mode is does not mean you are creating framework. You have to add other attributes like file operations, logs, security with encryption etc.
    – Sagar007
    Commented Dec 16, 2016 at 12:50
0

Yes, better to use the framework.

Framework means the set of rules or procedures that followed by team to achieve the objective.

The straight forward use of framework is easy maintenance and reusable.

As you mentioned, you used page object pattern. So you focused only on re-using of existing code. But the comments given by senior are also right, because you are not considered the part of passing input of scripts, not covered password decryption, easy reporting etc.


Some advantages of using a Test Automation framework:

  • Re-usability of code,
  • Maximum coverage,
  • Recovery scenario,
  • Low cost maintenance,
  • Minimal manual intervention,
  • Easy Reporting

Refer the link for selenium automation framework:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.