So I creating a scrolling function which looks like this
Feature: Dynamic page scrolling
Scenario: Scrolling function
* def ScrollHeight = function(){return script("document.body.scrollHeight")
* def ScrollFunction = function(){ script("window.scrollTo(0,document.body.scrollHeight)")
* def ScrollingFunction =
"""
function(){
var height = ScrollHeight()
while(true)
{ ScrollFunction()
var newHeight = ScrollHeight()
if(height === newHeight )
break;
height = newHeight
}
}
"""
So I created this in the same feature file in which I am having my test scenarios but I want to make this as a centralized function into another feature file from where I can use it in other feature files also. But I will not be able to call ScrollHeight and ScrollFunction from other feature files?
This is how I am trying this to create it in a new feature file Scrolling.feature
Feature: Dynamic page scrolling Function
Scenario: Scrolling function
*def obj = read('classpath:Testing.feature')
* def ScrollingFunction =
"""
function(){
var height = obj.ScrollHeight()
while(true)
{ obj.ScrollFunction()
var newHeight = obj.ScrollHeight()
if(height === newHeight )
break;
height = newHeight
}
}
"""
And my Testing.feature file looks like
Feature: Testing
Background:
* def ScrollHeight = function(){return script("document.body.scrollHeight")
* def ScrollFunction = function(){
script("window.scrollTo(0,document.body.scrollHeight)")}
Scenario: Test-1
* def fun = call read('classpath:Scrolling.feature')
* call fun.ScrollingFunction
But it does n't work for me