61. What is XPath?
Answer: Xpath is used to locate the elements. Using Xpath, we could navigate through elements and attributes in an XML document to locate web elements such as textbox, button, checkbox, image, etc in a web page.
62. What is the difference between “/” and “//” ?
Answer:
Single Slash(/) is used to create XPath with absolute path i.e., the xpath would be created to start selection from the document node/start node.
Double Slash(//) is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.
63. What are the verification points available in Selenium WebDriver?
Answer: In WebDriver, there is no inbuilt features for verification points. We can use TestNG or JUnit Assertions. It totally depends on our coding style. Some of the verification points are:
To check the page Title.
To check for certain Text.
To check for certain element(Textbox, button, dropdown, etc).
64. How to launch a browser using Selenium WebDriver?
Answer: WebDriver is an Interface. We create Object of a WebDriver Interface.
Selenium 3.X we use GeckoDriver, For Selenium Version<2.53 no GeckoDriver
To launch Firefox Driver:: WebDriver driver = new FirefoxDriver();
To launch Chrome Driver:: WebDriver driver = new ChromeDriver();
To launch Internet Explorer Driver:: WebDriver driver = new InternetExplorerDriver();
65. Is the FirefoxDriver a Class or an Interface?
Answer: It’s a Java Class which is Implementing WebDriver Interface.
66. What is the Super Interface of WebDriver?
Answer: SearchContext.
67. Explain the line of code WebDriver driver = new FirefoxDriver()?
Answer: WebDriver is an Interface and we are creating an object reference of type WebDriver instantiating an object of FirefoxDriver Class. We create a driver which is a reference variable of type WebDriver. We create a reference variable of the type WebDriver, so that we can use the same driver variable to work with any browser of our choice such at IEDriver, SafariDriver, etc. It’s also known as Dynamic Polymorphism.
68. What are the different exceptions you have in Selenium WebDriver?
Answer:
WebDriverException:
TimeoutException:
NoAlertPresentException
NoSuchWindowException
NoSuchElementException:
StaleElementReferenceException:
IllegalStateException:
69: How to login into any site if it is showing any authentication pop up for username and password?
Answer: In that case, we need to pass the username and password with the URL itself.
Syntax: http://username:password@url
e.g.: http://admin:[email protected]
70. How to input text in the textbox without calling the send keys?
Answer: Using JavaScript Executer.
Example:
//to initialize js object
JavascriptExecuter JS = (JavascriptExecuter)driver;
//to enter username
JS.executeScript(“document.getElementById(‘User’)).value=’[email protected]’ “);
//to enter password
JS.executeScript(“document.getElementById(‘User’)).value=’bjspassword’ “);
hi,your blog is very useful. all the questions are so challenging. thank you for posting all important questions.
http://www.trainingpune.in/selenium-training-in-pune.html