Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

java - spring cucumber Selenium fluent wait gives me driver=null

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();
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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()
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...