Though the practice that I have been following could be inappropriate. Still looking for a fix to my problem here :
I'm getting a StackOverflowError ::
java.lang.StackOverflowError
at com.my.package.pages.Selendroid.HomePage.<init>(HomePage.java:11)
at com.my.package.pages.Selendroid.LoginPage.<init>(LoginPage.java:14)
at com.my.package.pages.Selendroid.HomePage.<init>(HomePage.java:11)
AppiumBasePage ::
public class AppiumBasePage {
protected AppiumDriver driver;
HomePage ::
public class HomePage extends AppiumBasePage {
LoginPage loginPage = new LoginPage();
LoginPage ::
public class LoginPage extends AppiumBasePage {
HomePage homePage = new HomePage();
Q : How do I resolve this cyclic dependency and what exactly am I doing wrong here? Details would be great.
Edit : The details to what I want to achieve is - I would be having a lot of interrelated methods in both these classes. And instead of creating an object inside the functions where I wanted to use it multiple times, I want to have a single object of one page on another to use the methods defined in the former.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…