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.
driver.manage().window().maximize();
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();
proxy.setHttpProxy(PROXY)
.setFtpProxy(PROXY)
.setSslProxy(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.
obj.dragAndDrop(“From”,”To”).build().perform();
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 https://www.randelshofer.ch/monte/index.html 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.
Example:
<“input name=”Name Locator” value=”selenium”>Hello
driver.findElement(By.name(“Name Locator”)).getAttribute(“value”); //you get “Selenium”.
driver.findElement(By.name(“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);
Act.moveToElement(element).click().perform();



Other Posts

JDBC for Selenium

jdbc for selenium, jdbc driver for selenium, jdbc jar for selenium, jdbc api for selenium,...

Selenium grid

Selenium Grid is a server that allows tests to use web browser instances running on...

GIT

Understanding git fetch commandgit fetch origingit fetch command only downloads new data from a remote...

GIT

Get detail about a particular commitTo get the details about particular commit, you can do...

Java Interview Questions

Java Interview Questions Below are most frequently asked question in Interview for Java topic. Now...

Leave a Reply

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