- What is difference between driver.get(“”) and driver.navigate.to(“”);
ANS : get() is used to navigate particular URL(website) and wait till page load. driver. navigate() is used to navigate to particular URL and does not wait to page load.
2. Automation Design Patterns
You are bound to use a structured automation framework implementing a design pattern. This will help in code quality, maintainability, reusability, scalability, extensibility, and readability.
Choosing the right design pattern depends upon many factors such as complexity of the application to be tested, knowledge of the automation team members, estimated time of delivery of the application, etc.
A poor design eventually fails the automation framework, which, in turn yields flaky test results, code duplication, and poor code maintenance. To avoid this, we should identify problems in the automation framework and try to figure out the best suitable design pattern to be implemented.
Design patterns are broadly classified as Structural, Creational and Behavioral patterns.
We are having the following design patterns:
- Page Object Model Pattern -structural design pattern
- Factory Design Pattern – creational patterns
- Façade Pattern -structural design patterns
- Singleton Pattern -creational design pattern
- Fluent Page Object Model –
Page Object Model Pattern :

POM simplifies this and helps to update at one single location which will be used by those 20 different test class files.
In this design pattern web pages are represented as classes. Web page elements are defined as variables and user interactions are defined as methods. For example, the LoginPage class would have locators such as username, password, loginbtn and methods such as login(String username, String password).
Test classes use methods of these page classes whenever it needs to interact with the UI of the page with the help of the object of the respective page class. If any element is updated in any page, we just need to update the locator/ method of that page class only.
Page Object is a class that represents a web page and holds the web page elements and action methods. Page Factory is a way to initialize the web elements we want to interact with within the page object when you create an instance of it.
Page Object Model design pattern enhances test maintenance, reduces code duplication, and increases code readability and reusability. It is an object-oriented class that serves as an interface to a page of the Application Under Test (AUT). Page objects encapsulate web elements, or other class members and provide access to wrapper methods that hide all the logic.
Get table contents in selenium
public class TableCellValue{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver","C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String u="https://sqengineer.com/practice-sites/practice-tables-selenium/"; driver.get(u); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); // identify table WebElement t = driver.findElement(By.xpath("//*[@id='table1']/tbody")); // count rows with size() method List<WebElement> rws = t.findElements(By.tagName("tr")); int rws_cnt = rws.size(); //iterate rows of table for (int i = 0;i < rws_cnt; i++) { // count columns with size() method List<WebElement> cols = rws.get(i).findElements(By.tagName("td")); int cols_cnt = cols.size(); //iterate cols of table for (int j = 0;j < cols_cnt; j++) { // get cell text with getText() String c = cols.get(j).getText(); System.out.println("The cell value is: " + c); } } driver.quit(); } }