-am a beginner trying to implement hybrid framework in my project. -I have 3 pages login page, welcome page and appointment booking page -after enter username, psw, captcha it should navigate to welcome page and click group scheduling and should verify the url -instead of clicking group scheduling and verifying the url it is directly trying to finding the element in appointment booking page.
i have created methods in login page and hers the code
public class LoginPage extends ProjectSpecificMethods{
public LoginPage(RemoteWebDriver driver, ExtentTest node){
this.driver = driver;
this.node = node;
}
public LoginPage enterUserName(String data) {
WebElement ele = locateElement("id","username" );
clearAndType(ele, data);
return this;
}
public LoginPage enterPassword(String data) {
WebElement ele = locateElement("xpath","//input[text()='Password']");
clearAndType(ele, data);
return this;
}
public WelcomePage clickLogin() {
WebElement ele = locateElement("xpath","//input[@type='button']" );
clickWithNoSnap(ele);
return new WelcomePage(driver,node);
}
public RegistrationPage clickRegistrationlink() {
WebElement ele = locateElement("id","agentRegisterLinkForLogin" );
clickWithNoSnap(ele);
return new RegistrationPage(driver,node);
}
public LoginPage autoCaptcha() throws IOException, Exception{
WebElement ele = locateElement("id","captchaImage" );
WebElement ele1 =locateElement("id","catcha_text" );
printCaptcha(ele, ele1);
return this;
}
public AppointmentDetailPage enterCaptchAndClickLogin() {
WebElement ele = locateElement("id","catcha_text");
waitForCaptch(ele);
return new AppointmentDetailPage(driver,node);
}
}
and here is the welcome page
public WelcomePage(RemoteWebDriver driver, ExtentTest node){
this.driver = driver;
this.node = node;
}
public WelcomePage verifyWelcomePage() {
verifyUrl("https://agvfstuat.tasheelvfs.com/AgentVFSTasheel/opsys/auth/cnav");
return this;
}
public AppointmentDetailPage clickGroupScheduling() throws InterruptedException {
Thread.sleep(3000);
WebElement ele = locateElement("xpath","//*[text()='Group Scheduling']");
click(ele);
return new AppointmentDetailPage(driver,node);
}
appointment booking page
public class AppointmentDetailPage extends ProjectSpecificMethods {
public AppointmentDetailPage(RemoteWebDriver driver, ExtentTest node){
this.driver = driver;
this.node = node;
}
public void selectVisaType(String data) {
WebElement ele = locateElement("id","group_scheduling_visatype");
selectDropDownUsingText(ele, data);
}
testcase
public class TC003_BookAppointment extends ProjectSpecificMethods {
@BeforeTest
public void setValues() {
testCaseName = "bookappointment";
testDescription = "booking an appointment";
nodes = "appointment";
authors = "manoj";
category = "Smoke";
dataSheetName = "TC003";
}
@Test(dataProvider = "fetchData")
public void bookappointment(String username, String password,String visatype) throws IOException, Exception {
new LoginPage(driver, node)
.enterUserName(username)
.enterPassword(password)
.autoCaptcha()
.clickLogin()
.verifyWelcomePage()
.clickGroupScheduling()
.selectVisaType(visatype);
Thread.sleep(10);
;
error
bookappointment Oct 27, 2022 04:35:28 PM 0h 0m 28s+942msFail
Status Timestamp Details
check_circle 4:34:59 PM The Data :testmanilauser entered Successfully
check_circle 4:34:59 PM The Data :P@ssw0rd entered Successfully
check_circle 4:35:02 PM The Element with text: clicked
cancel 4:35:28 PM The Element with locator:id Not Found with value: group_scheduling_visatype
*-tried this testcase without framework its working as expected(going to appointment booking detail page)
*-tried writing welcome page methods in appointment bookingdetailpage (not working)