protractor angularJS global variables

前端 未结 2 1204
别跟我提以往
别跟我提以往 2021-01-19 17:32

I\'m using protractor with angularjs to create my e2e tests. I have many files for which my specs array is quite big and I want to share a common function across all files.

相关标签:
2条回答
  • 2021-01-19 17:38

    Yes, you can easily do that using the onPrepare()hook in the protractor configuration:

    exports.config = {
        // ...
    
        // A callback function called once protractor is ready and available, and
        // before the specs are executed
        // You can specify a file containing code to run by setting onPrepare to
        // the filename string.
        onPrepare: function() {
            // you can also add properties to globals here
        }
     };
    
    0 讨论(0)
  • 2021-01-19 17:56

    This works wonderfully...Just make sure you properly terminate the previous config params by using proper delimiter ',' .

            exports.config = {
               seleniumAddress: **,**
               onPrepare: function() {
                  browser.driver.manage().window().maximize();
               }**,**
               baseUrl:
               }
    
    0 讨论(0)
提交回复
热议问题