Ques.2 What is the use of driver.get(“URL”) and driver.navigate().to(“URL”) commands? Is there any difference between the two?
Ans. Both driver.get(“URL”) and driver.navigate().to(“URL”) commands are used to navigate to a URL passed as a parameter. There is a minor difference between the two commands-
Ques.9 How to prevent a test case from running using TestNG?
Ans. A Test method can be disabled from getting executed by setting the “enabled” attribute as false.
Ques.6 How can we handle window UI elements and window POP-ups using selenium?
Ans. Selenium is used for automating web-based applications only(or browsers only). If we want to handle window GUI elements then we can use tools like AutoIT. AutoIT is a freeware used for automating Windows GUI. The AutoIt scripts follow the simple BASIC language-like syntax. Also, it can be easily integrated with Selenium tests.
Ques.2 How can we submit a form in Selenium?
Ans. Using the submit() method we can submit a form in selenium.
Also, we can use the click() method for the same purpose.
Ques.2 How can we type text in a textbox element using Selenium?
Ans. With the help of the sendKeys() method, we can type text in a textbox-
Ques. Can we move back and forward in the browser using Selenium?
Ans. Yes, using driver.navigate().back() and driver.navigate().forward() commands, we can move backward and forward in a browser.
Ques.6 How to handle the HTTPS website in Selenium or how to accept the SSL untrusted connection?
Ans. Using profiles, we can handle accepting the SSL untrusted connection certificate. Profiles are basically a set of user preferences stored in a file.
Ques.9 How can we make one test method dependent on others using TestNG?
Ans. Using the ‘dependsOnMethods’ parameter inside @Test annotation in TestNG, we can make one test method run only after the successful execution of the dependent test method.
Ques.8 Explain the line of code Webdriver driver = new FirefoxDriver();.
Ans. This is one of the most frequently asked Selenium interview questions. In the line of code Webdriver driver = new FirefoxDriver(); ‘WebDriver’ is an interface and we are creating an object of type WebDriver instantiating an object of FirefoxDriver class.
Ques. What is the fundamental difference between XPath and CSS selectors?
Ans. Using driver.navigate().refresh() command. Using sendKeys(Keys.F5) on any textbox on the webpage. Using driver.get(“URL”) on the current URL or using driver.getCurrentUrl() Using driver.navigate().to(“URL”) on the current URL or
Ques. What are some advantages of the Selenium grid?
Ans. The advantages of the Selenium grid are-
Ques.5 What are some commonly encountered exceptions in Selenium?
Ans. Some of the commonly seen exceptions in Selenium are-