1

I've had a problem with the Selenium web driver trying to find a button on the page and click it. The page buffers every time so I implemented a wait time and it's still not working. Is there another command I should use or is this an easy fix?

Error:

//java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.WebElement.click()" because "this.facilitySelect" is null
 at com.katalon.kata.sample.testcase.simple.MakeAppointmentTest.shouldMakeAppointment(MakeAppointmentTest.java:40)].

Code:

package com.katalon.kata.sample.testcase.simple;
import com.katalon.kata.sample.Constants;
import com.katalon.kata.sample.page.CuraAppoinmentPage;
import com.katalon.kata.sample.page.CuraAppointmentConfirmPage;
import com.katalon.kata.sample.page.CuraHomePage;
import com.katalon.kata.sample.page.CuraLoginPage;
import com.katalon.kata.testng.TestTemplate;
import org.testng.annotations.Test;
import java.io.IOException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.concurrent.TimeUnit;

public class MakeAppointmentTest extends TestTemplate {

  private CuraHomePage curaHomePage = new CuraHomePage(Constants.baseUrl);

  private CuraLoginPage loginPage;

  //private CuraAppoinmentPage curaAppoinmentPage;

  //private CuraAppointmentConfirmPage curaAppointmentConfirmPage;
  @FindBy(id = "btnClose")
  private WebElement facilitySelect;
  
  @FindBy(id = "btnbillingModeOK")
  private WebElement bookAppointmentBtn;
  

  @Test
  public void shouldMakeAppointment() throws IOException {
    
   //curaHomePage.makeAppointment();
   curaHomePage.open();
    loginPage.login(Constants.username, Constants.password);
    curaHomePage.makerarr();
    for(int s=0;s< curaHomePage.array.length;s++){
      curaHomePage.openNext(curaHomePage.array[s]);
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      facilitySelect.click();

      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        bookAppointmentBtn.click();
    }
    driver.quit();
  }
}
Laurel
  • 5,965
  • 14
  • 31
  • 57

0 Answers0