What are the chalenges with Selenium Automation
What are the Selenium 4 features?
What is the difference btw WebDriver.findElement vs WebElement.findElement ?
driver.findElement(): Is to identify the element
It is for finding from the entire page using the given selector
WebElement.findElement();
First, it generates the the WebElement, and then the child element of the given element are searched based on the given selector. Ext: Used when you have multiple common locators on the page and you only need to drill down to unique one.
What is the difference btw Page Object Model and Page Factory?
Page Object Model(POM): Design pattern
POM is a Selenium design pattern; we can see it as a repository where we store all the WebElements. It is very easy to manage, reusability of code, and eliminates code duplication.
The key benefit if UI changes in the future, then we can update WebElements to Page Classes in POM or Object Repository Accordingly.
Page Factory: Design Pattern
Page Factory in Selenium WebDriver is an integrated concept or API. Here we follow again the same principle of keeping repository objects or page classes separate from test cases
Here we use @FindBy to find elements and to initialize WebElements using initElements process.
What are the locators that support selenium?
Name: Same as ID although is is not unique
CSS Selectors: Works on Element tags and attributes
XPath: Searches elements in DOM, Reliable but slow
Class name: Uses the class name attribute
TagName: Uses HTML tags to locate web elements
LinkText: Uses anchor text to locate web elements
Partial Link Text: Uses partial link text to find web elements
ID:
How to overcome StaleElementReferenceException in Selenium?
Stale - Outdater
The reference to an element is now “stale”; the element will no longer appear on the page’s DOM. In simple words, when you started interacting with it, the element you located using the findElement method disappeared.
Adding exception handling to your action end, if the exception in stale, try to locate the element after a simple wait for 500 milliseconds and repeat these actions until the action or max iterations have been successful.
Difference btw XPath and SCC selectors?
How to access the CSS selector using the nth (child) element?
Here is a syntax for using the CSS selector to access the nth attribute: <type>:nth-child(n)</type>
Ex: tr:nth-child(2)