Selenium @FindBy vs driver.findElement()
问题 Why should I use @FindBy vs driver.findElement() ? @FindBy forces me to move all my variables to a class level (when most of them only need to be at the method level). The only thing it seems to buy me is I can call PageFactory.initElements() , which handles lazy initialization for me. What am I missing? 回答1: Roughly speaking, @FindBy is just an alternate way of finding elements (the "usual way" being driver.findElement() as you said). The big advantage of that annotation is not itself,