How to do Web Automation Tests with Page Object Model, Java 1.8, Selenium 3.141.59
// Create a class constructor searchPage pageFactory
public homePage(WebDriver driver){
PageFactoryClass.initElements(driver,this);
}
// Create an object of class searchPage (This will call the constructor)
searchPage sPage;
@Test(priority = 1,description = "Search Test Process")
public void search_case() throws InterruptedException, IOException {
sPage = new searchPage(driver);
sPage.search_function("Test Deneme");
}
```java
// The primary use of WebDriverManager is the automation of driver management. For using this feature,
you need to select a given manager in the WebDriverManager API (e.g., chromedriver() for Chrome) and invoke the method setup().
@BeforeTest
public void setup(){
ChromeOptions chromeOptions = new ChromeOptions();
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver(chromeOptions);
}
https://github.com/bonigarcia/webdrivermanager
## Optimization
POM is preferred to improve code maintainability and readability by setting common methods and elements to a variable.
## Lessons Learned
In case of browser incompatibility with the driver that you have used locally, use an updated browser and update your driver.
If you do not want to encounter such problems, you can use the WebDriverManager made by bonigarcia. -> https://github.com/bonigarcia/webdrivermanager
// ## Related Projects
Here are some related projects
[Awesome README](https://github.com/bonigarcia/webdrivermanager)
## Distribution
Run this project to deploy
```terminal
To run your tests via terminal;
Open terminal in project home directory and run mvn clean install command.
Then run your test with the mvn test command.
mvn clean install
after
mvn test