Within my codebase, I have 3 distinct page objects: main.js, login.js, and menu.js. Each of these files contains functions that are named after the file itself, making up a series of tests.
- main : main()
- login : login()
- menu : menu()
For instance, in main.js, I have the following structure:
module.exports={
commands=[{
main:function(){
return this.click("@login")
}
}],
elements:{
login: {
locateStrategy:'xpath'
selector: ('//a[@name="Log in"]')
}
}
}
One test scenario involves executing main -> login -> menu.
I attempted to achieve this like so:
var main = client.page.main()
var login = client.page.login()
var menu=client.page.menu()
...
var ok=main.main()
if(!ok){
return ok
}else {
return login.login()&&menu.menu()
}
However, I consistently encounter this error message:
{ status: -1,
value:
{ error: 'invalid session id',
message: 'No active session with ID null',
stacktrace: '' },
errorStatus: 6,
error: '' }
I am curious about how calling the page object affects the client and what could be a viable solution to resolve this issue. Additionally, while searching for answers, I came across Multiple page objects in one test case, but unfortunately, it did not provide a direct solution as I need to reuse these objects multiple times (not just A->B->C, perhaps A->C->B or A->C).