Skip to main content
Reword to focus on the actual question
Source Link
Kate Paulk
  • 31.5k
  • 8
  • 55
  • 109

Constructor query What is the purpose of this constructor pattern

class LoginPage(){

///line of code
}

public LoginPage(WebDriver driver) {           
         this.driver = driver; 
         PageFactory.initElements(driver, this);
}

Can any onesomeone please explain the constructor part of the code. Why doI don't understand why we declare a constructor and pass the driver instance here. 

What ismakes passing the use of itdriver into the constructor such a common pattern?

Constructor query

class LoginPage(){

///line of code
}

public LoginPage(WebDriver driver) {           
         this.driver = driver; 
         PageFactory.initElements(driver, this);
}

Can any one please explain the constructor part of the code. Why do we declare a constructor and pass the driver instance here. What is the use of it?

What is the purpose of this constructor pattern

class LoginPage(){

///line of code


public LoginPage(WebDriver driver) {           
         this.driver = driver; 
         PageFactory.initElements(driver, this);
}

Can someone please explain the constructor part of the code. I don't understand why we declare a constructor and pass the driver instance here. 

What makes passing the driver into the constructor such a common pattern?

formatting
Source Link
Bharat Mane
  • 6.8k
  • 11
  • 41
  • 69

class LoginPage(){

///line of code }

public LoginPage(WebDriver driver) {
this.driver = driver; PageFactory.initElements(driver, this); }

class LoginPage(){

///line of code
}

public LoginPage(WebDriver driver) {           
         this.driver = driver; 
         PageFactory.initElements(driver, this);
}

Can any one please explain the constructoconstructor part of the code. Why do we declare a constructor and pass the driver instance here. What is the use of it?

class LoginPage(){

///line of code }

public LoginPage(WebDriver driver) {
this.driver = driver; PageFactory.initElements(driver, this); }

Can any one please explain the constructo part of the code. Why do we declare a constructor and pass the driver instance here. What is the use of it?

class LoginPage(){

///line of code
}

public LoginPage(WebDriver driver) {           
         this.driver = driver; 
         PageFactory.initElements(driver, this);
}

Can any one please explain the constructor part of the code. Why do we declare a constructor and pass the driver instance here. What is the use of it?

Source Link
Krishna
  • 21
  • 1
  • 2

Constructor query

class LoginPage(){

///line of code }

public LoginPage(WebDriver driver) {
this.driver = driver; PageFactory.initElements(driver, this); }

Can any one please explain the constructo part of the code. Why do we declare a constructor and pass the driver instance here. What is the use of it?