A locator is a way to identify elements on a page. Below is the list of these locators of Selenium WebDriver:
ID - driver.findElement(By.id (<element ID>))
Name - driver.findElement(By.name (<element name>))
ClassName- driver.findElement(By.className (<element class>))
LinkText - driver.findElement(By.linkText (<linktext>))
Partial LinkText - driver.findElement(By.partialLinkText (<linktext>))
TagName - driver.findElement(By.tagName (<htmltagname>))
CSS Selector - driver.findElement(By.cssSelector (<css selector>))
XPath - driver.findElement(By.xpath (<xpath>))
An Assert in Selenium is used to validate that certain conditions are met during a test run. It checks whether the expected outcome of an action matches the actual result. If the condition specified in the assert statement is true, the test will continue to run.
A Verify in Selenium is used to check if certain conditions are met without stopping the test execution. Unlike Assert, even if the condition specified in the Verify statement is false, the test will continue to run to the end.
Implicit Wait
An implicit wait is a global setting that applies to all elements in a Selenium script. It waits a specified time before throwing an exception if the element is not found. We can set the wait once per session and can’t change it later. The default value is 0.
Explicit Wait
An explicit wait is a more flexible wait that allows us to wait for a specific condition to be met before continuing test execution.
Fluent Wait
A fluent wait is another type of explicit wait that allows for more fine-grained control over the waiting mechanism. It enables us to define the expected condition and the polling mechanism to check for the particular condition to be met.
A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes:
A constructor has the same name as that of the class and does not have any return type. For example,
class Hello {
Hello() {
// constructor body
}
}
@BeforeMethod: This will be executed before every @test annotated method.
@AfterMethod: This will be executed after every @test annotated method.
@BeforeClass: This will be executed before first @Test method execution. It will be executed one only time throughout the test case.
@AfterClass: This will be executed after all test methods in the current class have been run
@BeforeTest: This will be executed before the first @Test annotated method. It can be executed multiple times before the test case.
@AfterTest: A method with this annotation will be executed when all @Test annotated methods complete the execution of those classes inside the <test> tag in the TestNG.xml file.
@BeforeSuite: It will run only once, before all tests in the suite are executed.
@AfterSuite: A method with this annotation will run once after the execution of all tests in the suite is complete.
@BeforeGroups: This method will run before the first test run of that specific group.
@AfterGroups: This method will run after all test methods of that group complete their execution
For Call
+91-9999385943For Call
+91-9999568773