'How to instantiate a page object model in a Beforetest method and use the instance in different test methods

l am having to repeat instantiating a particular page objects in different test methods. l was thinking if there is a way to instantiate the page object once and use that instance in all the different test methods. Below is my code for clarity

    @Test
    public void FilterByAll() {
         KYCScreenPage kycScreen = new KYCScreenPage(_driver);
         kycScreen.KycScreenNav().click();
    }
    
    @Test
    public void KycDownload() {
        
     KYCScreenPage kycScreen = new KYCScreenPage(_driver);
     kycScreen.KycScreenNav().click();
     kycScreen.KYCDownload().click();
     
    }

l want to instantiate KYCScreenPage once and use the instance in all the test methods.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source