Selenium Interview Questions

Selenium Interview Questions

Below are most frequently asked question in Interview for selenium topic. Below content is for interview preparation you can read below questions and answers before your interview to revised the concepts you already know.

21.How to We maximize window using selenium Webdriver?
We can maximize window using selenium Webdriver using below code.
22 .How to set Proxy in IE and Chrome?
  • The easiest and recommended way is to manually set the proxy on the machine that will be running the test.
  • If that is not possible or we want your test to run with a different configuration or proxy, then we can use the following technique that uses a Capababilities object. This temporarily changes the system’s proxy settings and changes them back to the original state when done.
String PROXY = “localhost:8080”;

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new InternetExplorerDriver(cap);
23 .How to perform drag and drop in selenium?
We can perform drag and drop using Actions class Actions obj=new Actions(driver);
  • “From” will store xpath of source point.
  • “To” will store xpath of desination point.
24.How to get page source in selenium?
We can get page source using getPageSource function. Webdriver driver =new ChromeDriver(); String pageSource = driver.getPageSource();
25.How will you record script exection video in selenium?
By Monte Media Library we can record script exection video link for jar given below add the JAR file to the Libraries of the current project and use predefine start() and stop() functions to start and stop video recording.
26.Why selenium grid is used?
It is a tool used to run parallel tests across different machines and different browsers simultaneously which results in minimized execution time because it allows us to execute multiple instances of WebDriver.
27 .Explain verifyElementPresent() and verifyText() functions in selenium?
verifyElementPresent: We use verifyElementPresent command when we have to test for the presence of a specific UI element, rather than its content. verifyText: We use verifyText comman when we have to verify that specific text appears at a specific location on the page relative to other UI components on the page.
28.In selenium Webdriver ChromeDriver class extends RemoteWebDriver class true of false?
True, In selenium Webdriver ChromeDriver class extends RemoteWebDriver class.
29.findElement or findelements can throw which Exception?
findElement or findelements can throws NoSuchElementException.
30.What is the difference between getText() and getAttribute() in Selenium WebDriver?
  • getText() : It fetch the text that containing one of any attribute in the HTML tag.
  • getAttribute() : delivers the innerText of a WebElement. Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.
<“input name=”Name Locator” value=”selenium”>Hello
driver.findElement(“Name Locator”)).getAttribute(“value”); //you get “Selenium”.
driver.findElement(“Name Locator”)).getText(); //you get “Hello”.
31.What is the difference between isSelected() , isEnabled() and isDisplayed() functions of selenium Webdriver?
Difference between isSelected() , isEnabled() and isDisplayed() functions of selenium Webdriver is
  • isSelected() : It verify whether element is selected or not such as radio button or checkbox. @return True if the element is currently selected or checked, false otherwise.
  • isEnabled() : It verifies whether element currently enabled or not? This will generally return true for everything but disabled input elements.
  • isDisplayed() :It verifies whether element is displayed or not. This method avoids the problem of having to parse an element’s “style” attribute.
32.What is the difference between isPresent() and isDisplayed() functions in selenium Webdriver?
  • isPresent() – This will check if the element with the given locator is present in DOM or not, if its css property is style=display:none but element is present in DOM then it will returns true else it will return false.
  • isDisplayed() – This will check if the element with the given locator is present and if its css property is style=display:none returns false else it will return true.
33.What is the difference between maximize() and fullscreen() functions?
  • maximize(): Maximizes the current window if it is not already maximized.
  • fullscreen() : Fullscreen the current window if it is not already fullscreen , it is same like pressing F11 function key on the keyboard.
34.What manage() function returns in selenium webdriver?
The manage() function returns an option interface.
35.What is the return type of getWindowHandle() function?
Return type of getWindowHandle() function is string.
36.What is the return type of getWindowHandles() function?
Return type of getWindowHandles() function is Set.
37. What is the return type of findElement() function?
Return type of findElement() function is WebElement.
38.What is the return type of findElements() function?
Return type of findElements() function is List.
39.How to perform mouse action in selenium?
We can perform mouse action using Action class in selenium
Actions Act = new Actions(driver);

Leave a Reply

Your email address will not be published. Required fields are marked *