UI Automation is one of the Testing / Validation activity that tis mainly used to validate UI of an application. The testing covers each task that the user is interactive to perform any operation in the application. There are different languages and framework that could let us to perform the UI Automation for various types of application as per their implementation as Web , Desktop, or Device.
Web Driver
It is a web framework that could let us to interact to the web elements. This could help to automate out test and work with web elements. There are various types of web driver for each types of browsers. some of the web drivers are
Question: – What possible web driver you know?
Answer : –
- ChromeDriver() called ChromeDriver
- InternetExplorerDriver()
- FirefoxDriver() – Called GeckoDriver
- SafariDriver()
- Microsoft Edge
ChromeDriver driver= new ChromeDriver();
Locator
These are used to identify elements that could let us to reach and interact to the UI component The locator can be implemented through various function such as className,Id,TagName,cssSelector,xPath and many more. In order to identify the locator, there are many techniques like Inspect Element /Dev tools, UI Recorder, Appium Inspector for device related applications and many other tools and tecniques.
Question : – What possible Locator you know to locate an Element?
- Answer: – className,Id,TagName,cssSelector,xPath and many more.
Techniques to Identify Locator
There are different techniques and tools that could let us to identify locator that we want to work on the UI automation. some of the techniques or tools are
Question :- What techniques or tools we use to search element locator?
Answer: –
- Dev Inspector Element
- Appium Inspector
- Recorder – UI Records
- Many others tools
Design Patter of UI -Automation
The design patter for UI Automation starts with the steps, step-definition and POM – Page Object Model
Question: – What design patter for UI Automation that you are aware of it?
- Answers: –
- Steps – In which the scenarios are described – Having Feature, Preconditions, Scenarios
- Step Definition : = Define the steps further to interact to the POM and perform as well assertion,
- POM :- It is a place where each page is represented by a class file. This technique helps to eliminate code duplication and also makes test maintenance more convenient and easy.
Figure 1.1 :- Design Patterns
Delay
It is common techniques that is used in automation ignorer to interact to the element that we are waiting to do a certain action. There are several ways to implement delay in our test automation code. The following are the three know types of delay – Implicit, Explicit, and Fluent Wait.
Questions: – What possible delay exists?
Answers –
- Implicit Not condition is defined and the Web driver is waiting for a certain time without any condition
- Explicit There is a condition the web driver is waiting to happen/wait until a certain condition occurs before proceeding with executing the code.
- Fluent Wait looks for a web element repeatedly at regular intervals until timeout happens or until the object is found.
public static WebDriver driver;
public final static int TIMEOUT = 10;
driver = new ChromeDriver();
#Method -1
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(TIMEOUT));
#Method-2
driver.manage().timeouts().implicitlyWait(TIMEOUT, TimeUnit.SECONDS);
#Method -3
Thread.sleep(TIMEOUT);
Figure 1.2 :- Implicit Wait
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(text(),'COMPOSE')]")));
Figure 1.3 :- Explicit Wait