spring cucumber Selenium fluent wait gives me driver=null

157 Views Asked by At

I am trying to use fluent wait

@Component
@Scope(SCOPE_CUCUMBER_GLUE)
public class UserCreationPageImpl extends BaseBinariosPage implements UserCreationPage {
     Wait<WebDriver> wait = new FluentWait<WebDriver>( driver )
            .withTimeout(Duration.ofSeconds(30))
            .pollingEvery(Duration.ofSeconds(5))
            .ignoring(NoSuchElementException.class); 

but when I debug I got drive=null

here is where I am instanciate the driver

@Page
public abstract class BaseBinariosPage {
    @Autowired
    protected WebDriver driver;
    @Autowired
    private QAStarterConfigProperties qaStarterConfigProperties;

    public BaseBinariosPage() {
    }

    @Init
    public void init() {
        this.driver.get(this.qaStarterConfigProperties.getAppUrl() + this.getPageEndPoint());
        PageFactory.initElements(this.driver, this);
    }

    protected abstract String getPageEndPoint();
}
1

There are 1 best solutions below

0
On

When you declare a variable it will be assigned null value by default. There is no constructor in your BaseBinariosPage that creates a driver object, how do you expect it to have a driver object.

Add something like:

public BaseBinariosPage() {
  driver = new ChromeDriver()
}