Explain XPath Absolute and XPath attributes.
XPath Absolute:
- XPath Absolute enables users to mention the complete XPath location from the root HTML tag to the specific elements.
- Syntax: //html/body/tag1[index]/tag2[index]/…/tagN[index]
- Example: //html/body/div[2]/div/div[2]/div/div/div/fieldset/form/div[1]/input[1]
XPath Attributes: - XPath Attributes is always recommended when you don’t have a suitable id or name attribute for the element you want to locate.
- Syntax: //htmltag[@attribute1=’value1′ and @attribute2=’value2′]
- Example: //input[@id=’passwd’ and @placeholder=’password’]
What is the difference between “type” and “typeAndWait” command?
“type” command is used to type keyboard key values into the text box of software web application. It can also be used for selecting values of combo box whereas “typeAndWait” command is used when your typing is completed and software web page start reloading. This command will wait for software application page to reload. If there is no page reload event on typing, you have to use a simple “type” command.
What are the different ways of locating a web element in Selenium?
In Selenium, web elements are identified and located with the help of Locators. Locators specify a target location which uniquely defines the web element in the context of a web application. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:
- ID
- ClassName
- Name
- TagName
- LinkText
- PartialLinkText
- Xpath
- CSS Selector
- DOM
What is the difference between “/” and “//” in XPath?
Single Slash “/”: Single slash is used to create XPath with absolute path.
Double Slash “//”: Double slash is used to create XPath with the relative path.
What is the difference between findElement() and findElements()?
findElement(): It is used to find the first element within the current page using the given “locating mechanism”. It returns a single WebElement.
findElements(): It uses the given “locating mechanism” to find all the elements within the current page. It returns a list of web elements.
How many types of WebDriver API’s are available in Selenium?
The list of WebDriver API’s which are used to automate browser include:
- AndroidDriver
- ChromeDriver
- EventFiringWebDriver
- FirefoxDriver
- HtmlUnitDriver
- InternetExplorerDriver
- iPhoneDriver
- iPhoneSimulatorDriver
- RemoteWebDriver