Sunday 15 January 2012

testing - Protractor - How to separate each test to one file and separate variabiles -


I have some complex testoster test, but everything is in one file. Where I am at the top of loading all the variables like this:

  var userLogin = "John";  

And after that in the code I use it together.

What do I need to do? 1. Separate file to all variabiles (some config files) 2. Each test for a file

1- I try to create config.js, where I add all the variables and I need it in Protractor.config, it is being loaded properly When I use any of these variabiles, some tests do not work with it (failing with the test "username not defined") I know that there is a way where I conf in each exam script Ig.file is required, but it is not really the best option in my eyes.

2 - How can I know what I did in the previous script, if it is different, for example how do I know how to log in?

Thank you.

There are many things that you can use.

2) How can I know what I did in the previous script, like how I am logging in, for example how?

This is where it can help:

Put any duplicate setup and tidown code in the suite, before Jasmine and before each event Global offers. As the name implies, each function is organized before each function before each function, and after each function, after each function a function is called.

Party for spectacles 1:

First of all the function is called only once all the specs are played in the description, and after all The function is called after all glasses have ended. These tasks can be used to speed up the trial suite with expensive setup and Teandown.


1) I try to create config.js where I add all the variables and miles, it is loading the problem properly in protractor.conf.js That's when I use any variable in any of these tests, it is not working (failing with the test "username not defined") I know there is a way where I require requre in config.file Exam scripts but it really works best in my eyes Lp is not.

One option I have personally used must be to create a config.js file with reusable configuration variables You need many tests and once the file is required - in the Proprietor Config - then set it as the params configuration key value:

  Var config = require (". / Config.js"); Export.config = {params: config, ...};  

Where config.js is, for example:

  var config; Config = {user: {login: "user", password: "password"}}; Module.exports = config;  

Then, you will not need in every test for config.js , but instead, you browser. Params . For example:

  is expected (browser.params.user.login) .toqual ("user");  

In addition, if you need any type of global testing preparation step , you can do this on ; Prepare () function, see Example configuration that provides a "global" login step.

And another quick note: You custom universally defined variables (such as the underlying browser or launcher ), Set using the code> global using onPrepare . For example, I have defined protractor.expected Conditions as a custom global variable:

  transparency: function () {global.EC = Protector. Estimated terms; }  

Then, in the tests, nothing is required, the EC will be available in the scope of the variable, such as:

  Browser.wight (EC. InvisibilityOf (scope.page.dropdown), 5000)  

In addition, using reusability and modularity to solve your problem Will help


No comments:

Post a Comment