Credo Systemz

TOP 100 INTERVIEW QUESTIONS FOR SELENIUM

Here is the list of top 100 interview questions for SELENIUM to be asked recently in all the top companies with answers.

Frequently asked Selenium Interview Questions

Q1. What is Selenium?

Answer:Selenium is an open source, suite of tools for automated web testing.  It provides a single interface that lets you write test scripts in programming languages like Ruby, Java, Node JS, PHP, Perl, Python, and C#, among others. It is composed of

  • Selenium IDE (Integrated Development Environment):  It is a tool for recording and playing back which is a firefox plugin
  • WebDriver and RC:  It provides the APIs for a variety of languages like Java, .NET, PHP, etc. With most of the browsers Webdriver and RC work.
  • Grid: With the help of Grid we can distribute tests on multiple machines so that test can be run parallel which helps in cutting down the time required for running in browser test suites

Q2.How will you find an element using Selenium?

Answer:Every object or control in a web page is referred as elements, there are different ways to find an element in a web page they are

  • ID
  • Name
  • Tag
  • Attribute
  • CSS
  • Linktext
  • PartialLink Text
  • Xpath et

Q3. What are the testing types supported by Selenium? 

Answer:Selenium supports Regression testing and Functional testing. 
Regression testing - It is a full or partial selection of already executed test cases that are re-executed to ensure existing functionalities work fine.
Functional testing - It involves the verification of every function of the application with the required specification. 

Q4. Define is Automation Testing?

Answer:The use of automation tools for writing and executing the test cases with no manual involvement for executing the Automated Test Suite is called Automation Testing.
The Automation tools are preferred by Testers to write the test cases or test scripts and then group them all into Test Suites which are designed to execute manually designed test cases without any human intervention. 

Q5. What is the difference between the Absolute path and the Relative Path?

Answer:Absolute Path-starts from the root node and ends with the desired elements node with a single slash (/)
Example: /html.body/div/td/input
Relative Path-starts from any node in between and to the desired elements node with a double slash (//)
Example: //input/example[@id=name]

Q6. What is the difference between Selenium 2.0 and Selenium 3.0? 

Answer: Selenium 2.0 is a tool that makes the development of automated tests for web applications easier which represents the merger of the original Selenium project with the WebDriver project. Selenium RC got deprecated since the merge, however, was used for backward compatibility.
Selenium 3.0 is the extended version of Selenium 2.0. It is inherently backward compatible and does not involve Selenium RC. The new version came along with several bug fixes and increased stability. 

Attend a Free Online Mock Interview

Q7. What is Selenese? How is it classified?

Answer: Selenese is the set of Selenium commands which are used to test the web application. The tester can test the broken links, the existence of some object on the UI, Ajax functionality, alerts, window, list options, and a lot more using Selenese.There are three types of Selenese and they are,

  • Actions: to perform interactions and operations on the target elements.
  • Accessors: for storing the values in the variables.
  • Assertions: to be used as checkpoints to keep track of the sequential flow of commands.

Q8. Why should I use Selenium?

Answer:

  • Open-source
  • Large support from the community and the user base is huge
  • Cross-browser compatibility (Firefox, Chrome, Edge etc.,)
  • Multiple programming language support (Python, Java, Perl etc.,)
  • Every day or regular repository developments
  • Distributed Testing is also supported.

Q9. Explain Implicit wait, explicit wait and Fluent wait?

Answer: Implicit wait: Set the timeout for a specific amount of time for all the successive web elements. In this specified time, the web driver searches for all the web elements before throwing the NoSuchElementException.
Explicit wait: We can tell the Web Driver to wait for certain conditions before throwing the ElemntNotVisibleException.
Fluent wait: It’s a slight extension for the explicit wait. Apart from waiting for certain conditions to be met, we can also set the frequency with which we check the condition before throwing the ElementNotVisibleException.

Q10. What is assertion in Selenium and its types of assertion?

Answer: Assertion is used as a verification point which verifies that the state of the application conforms to what is expected.  The types of assertion are “assert”, “Verify” and “waitFor”.

Q11. What is an Object Repository and how we can create the Object Repository in Selenium?

Answer: The collection of web elements that belongs to the application under test along with their locator values is referred as Object Repository.The only thing is the locators are stored in a centralized location than hard coding them in the test scripts. While coming to Selenium, the objects can be stored in Excel also and can be used to populate them in the script whenever required. 

Q12. Explain the difference between single and double slash in X-path?

Answer:Single slash ‘/ ’-start selection from the document node that allows to create ‘absolute’ path expressions.
Double Slash ‘// ’-start selection matching anywhere in the document that enables to create ‘relative’ path expressions.

Q13. What is JUnit Annotations and what are different types of annotations which are useful?

Answer: Annotation is a special form of syntactic meta-data can be added to Java source code. Variables, parameters, packages, methods and classes are annotated some of the Junit annotations which can be useful are:

  • Test
  • Before
  • After
  • Ignore
  • BeforeClass
  • AfterClass
  • RunWith

Q14. Mention the types of navigation commands ?

Answer:

  • driver.navigate().to("https://www.ebay.in/"); - Navigates to the provided URL
  • driver.navigate().refresh(); - This method refreshes the current page
  • driver.navigate().forward(); - This method does the same operation as clicking on the Forward Button of any browser. It neither accepts nor returns anything.
  • driver.navigate().back(); - This method does the same operation as clicking on the Back Button of any browser. It neither accepts nor returns anything.

Q15. What is the same-origin policy? How can we avoid it?

Answer:The same origin policy is introduced for security reasons which ensure that we cannot access the script from another site. The source code which is loaded within the browser can only be operated within that website’s domain. It can be avoided by using the proxy-injection method. In this method, the browser is tricked using the Selenium’s server to be a real URL (fictional URL).

Q16. What are the four parameters to be passed in Selenium?

Answer: Four parameters that have to pass in Selenium are

  • Host
  • Port Number
  • Browser
  • URL

Q17. What is Page Object Model?

Answer: Every webpage of the application has a corresponding page class that is responsible for locating the web elements and performing actions on them. Page Object Model is a design pattern that helps create object repositories for the web elements. POM improves code reusability and readability. Multiple test cases can be run on the object repository.

Q18. How does Selenium handle Windows-based pop-ups?

Answer: Selenium was designed to handle web applications. Windows-based features are not natively supported by Selenium. However, third-party tools like AutoIT, Robot, etc can be integrated with Selenium to handle pop-ups and other Windows-based features. 

Q19.What is the difference between the getwindowhandle() and getwindowhandles()?

Answer: getwindowhandles(): is used to get the address of all the open browsers and returns the data type of Set <String>.

getwindowhandle(): is used to get the address of the current browser window where it’s focused on and returns the data type of String.

Q20.What is a heightened privileges browser?

Answer: The purpose of heightened privileges allows websites to do something that is not commonly permitted.  The key difference is that the browsers are launched in a special mode called heightened privileges.  By using these browser modes, Selenium core can open the AUT directly and also read/write its content without passing the whole AUT through the Selenium RC server.

Q21.What is the difference between setSpeed() and sleep() methods?

Answer:These methods will delay the speed of the execution. 
Thread.sleep(): The current thread will stop for a specified period of time. It only waits once when the command is given and takes only a single argument that is Integer format. 
set sleep(): This command will stop the execution for every selenium command which is used only for demonstration purposes and also for a slow web application. 

Q22. What are the advantages of Selenium?

Answer: Selenium supports C#, PHP, Java, Perl, Python and different OS like Windows, Linux and Mac OS. It has got powerful methods to locate elements (Xpath, DOM , CSS).It has highly developer community supported by Google.

Q23. Explain what are the JUnits annotations linked with Selenium?

Answer: The JUnits annotation linked with Selenium are
  • @Before public void method() – It will perform the method () before each test, this method can prepare the test.
  • @Test public void method() – Annotations @Test identifies that this method is a test method environment.
  • @After public void method()- To execute a method before this annotation is used, test method must start with test@Before.

Q24. What is Object Repository?

Answer: An object repository is an essential entity in any UI automations which allows a tester to store all objects that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.

Q25. What are regular expressions and how can we use regular expressions in Selenium?

Answer: The Search patterns are represented using the special Text string called the regular expressions. Regexp is the keyword that can be used as a prefix to treat a text in Selenium as a regular expression.

Q26. Explain how Selenium Grid works?

Answer: Selenium Grid sent the tests to the hub and these tests are redirected to Selenium Webdriver, which launch the browser and run the test.  With entire test suite, it allows for running tests in parallel.

Q27. Explain how you can find broken images in a page using Selenium Web driver?

Answer:To find the broken images in a page using Selenium web driver is

  • Get XPath and get all the links in the page using tag name
  • In the page click on each and every link
  • Look for 404/500 in the target page title

Q28. How can you verify the specific position of a web element?

Answer: VerifyElementPositionLeft and verifyElementPositionTop commands are used for the pixel comparison by identifying the position of the element from the left and top of the web page respectively.

Q29. What are the advantages or Benefits of Selenium RC?

Answer:
  • Data can be read or write to or from .xlsx, .csv, .txt etc.,
  • Dynamic objects and Ajax based UI elements can be handled.
  • Conditional statements and Iterations functionalities can be used to improve and enhance performance and flexibility.
  • Support for any programming languages and Operating systems.
  • Selenium RC can be used on any browser which is enabled with Java script.

Q30. Mention 5 different exceptions we had in Selenium web driver?

Answer: The 5 different exceptions are

  • WebDriverException
  • NoAlertPresentException
  • NoSuchWindowException
  • NoSuchElementException
  • TimeoutException

Q31. What are Breakpoints and Start points in Selenium?

Answer:Break points: The flow of execution is stopped using the breakpoints. By doing this we can verify that the code is working in an expected manner or not.
Start points: The point from where the execution should begin is determined by the start points. When you want to run a test script from the middle of the code or a breakpoint, we use these.

Q32. How will you use Selenium to upload a file?

Answer: “Type”command can be used to type in a file input box of upload file. Then use “Robot” class in Java to make file upload work.

Q33. How do we use findElement () and findElements ()?

Answer: findElement() is used to access any single element on the web page. It returns the object of the first matching element of the specified locator.
Syntax: WebElement element = driver.findElement(By.id(example));
findElements() is used to find all the elements in the current web page matching the specified locator value. All the matching elements would be fetched and stored in the list of Web elements.
Syntax: List <WebElement> elementList = driver.findElements(By.id(example));

Q34. How to take screenshots in WebDriver?

Answer:TakeScreenshot interface can be used to take screenshots in WebDriver. getScreenshotAs() method can be used to save the screenshot File scrFile = ((TakeScreenshot)driver).getScreenshotAs(outputType.FILE);

Q35. What are core extensions?

Answer: To “extend” the defualt functionality provided by Selenium Function Library, you can create a Core Extension which are also called “User Extension”. Download ready-made Core Extension created by other Selenium enthusiats.

Q36.Why Selenium RC is used?

Answer:Selenium IDE does not directly support many functions like condition statements, Iteration, logging and reporting of test results, unexpected error handling and so on as IDE supports only HTML language.  To handle such issues Selenium RC is used  it supports the language like Perl, Ruby, Python, PHP using these languages we can write the program to achieve the IDE issues.

Q37.What are the advantages of RC?

Answer:RC can read or write data from/ to .xls, .txt, etc which handle dynamic objects and Ajax based UI elements. Loops and conditions can be used for better performance and flexibility. It supports many Programming languages and Operating Systems. For any JAVA script enabled browser Selenium RC can be used.

Q38. What are the element locators that can be used to locate elements on web page in selenium IDE?

Answer:

  • X-path locators
  • Css locators
  • Html id
  • Html name

Q39. Mention what is Listeners in Selenium WebDriver?

Answer: Listeners listen to the event defined in the selenium script and behave accordingly. It allows customizing TestNG reports or logs. There are two main listeners i.e. WebDriver Listeners and TestNG Listeners.

Q40. Mention what is IntelliJ?

Answer: Intellij is an IDE that helps you to write better and faster code for Selenium. It can be used in the option to Java bean and Eclipse.

Q41. Mention in what ways you can customize TestNG report?

Answer:Customize TestNG report in two ways,

  • Using ITestListener Interface
  • Using IReporter Interface

Q42.What is the major difference between driver.close() and driver.quit()?

Answer: driver.close():closes the browser’s current window. If multiple windows are open, the current window of focus will be closed.
driver.quit():When quit() is called on the driver instance and there are one or more browser windows open, it closes all the open browser windows.

Q43. What are the verification points that are available in Selenium?

Answer: Selenium IDE: Verify and Assert commands
Selenium Web Driver: This does not have any built-in features for verification and always depends on our coding style. Some examples can be like checking the page title, checking for certain text in the page, checking for a certain element like textbox, dropdown, field etc.,

Q44.Can Selenium handle windows-based pop-up?

Answer: Selenium is an automation testing tool that can work with only web applications. Therefore, the pop-up in windows cannot be handled by Selenium. But, by integrating with the third-party tools we can overcome this problem.

Q45. List the advantages of Web driver over Selenium server?

Answer:

  • If Selenium web driver is used, then no need to use the dependency of the selenium server.
  • Selenium server provides us with the functionality of Selenium RC for the backward compatibility.
  • Selenium server acts as a middleware for the communication between browsers and the application. Whereas, the Selenium web driver directly calls the browser to support automation.

Q46. How can you debug the tests in the Selenium IDE?

Answer:

  • We need to first insert the breakpoints where we need to debug and execute the test step by step. 
  • Later, Run the test case.
  • After this, the execution stops at the point where the breakpoint is kept.
  • You can click on the Run button to continue the execution of all the commands sequentially.

Q47. How can you handle working with multiple windows in Selenium?

Answer: selectWindow() command in Selenium can be used to switch among the working windows. The distinguishing factor among all the windows is the title of the window.

Q48. Can you mention why do you need the Session handling in Selenium?

Answer: Session handling is very important while working with Selenium because while working with the test case scenarios we need to establish the communication between the browser and the application when executing the commands. There can be an issue where while running a particular test script, another test script can be triggered within the same host and same type of browser. This is the most important part and the reason why we need the session handling.

Q49. What is Locator and how do we locate an element in Selenium?

Answer: The elements of the web page are found and matched using locators to interact with. There are different kinds of locators to identify different types of elements on the web page. They are as follows,

  • ID
  • Name
  • Class
  • Partial Link
  • XPath
  • CSS Selector
  • Link Text

Q50. Which API is used for database testing in the Selenium web driver?

Answer: JDBC (Java Database connectivity) is used for database testing in Selenium. This allows us to write the SQL (Structured Query Language) queries and execute them.

Q51. Can you explain how can you handle colours in web driver?

Answer: We can use the command getCssValue(arg0) to fetch the colors by sending the color as the argument.

Q52. Is Selenium a framework?

Answer: Yes, selenium is a software testing framework for web applications that allows automating web app testing. With languages like Java, Python, Ruby, C#, you can write test scripts to run against browsers and VMs.

Q53. For Database Testing in Selenium Webdriver what API is required?

Answer: JDBC (Java Database Connectivity) API is required for database testing in Selenium that allows to execute  SQL statements.

Q54. Does primavera loads cash in and cash out in same schedule?

Answer:While working with Selenium, Session Handling is needed because during test execution, the Selenium WebDriver has to interact with the browser all the time to execute given commands. At the time of execution, it is also possible that, before current execution completes, someone else starts execution of another script, in the same machine and in the same type of browser. So to avoid such situation you need Session Handling.

Q55.Mention what are the challenges in Handling Ajax Call in Selenium Webdriver?

Answer:The challenges faced in Handling Ajax Call in Selenium Webdriver are

  • Using “pause” command for handling Ajax call is not completely reliable. Long pause time makes the test unacceptably slow and increases the testing time. Instead, “waitforcondition” will be more helpful in testing Ajax applications.
  • It is difficult to assess the risk associated with particular Ajax applications.
  • Given full freedom to developers to modify Ajax application makes the testing process challenging.
  • Given full freedom to developers to modify Ajax application makes the testing process challenging.
  • Creating automated test request may be difficult for testing tools as such AJAX application often use different encoding or serialization technique to submit POST data.

Q56. How do you identify an object using selenium

Answer: To identify an object using Selenium we can use isElementPresent(String locator)isElementPresent takes a locator as the argument and if found returns a Boolean.

Q57. Mention why to choose Python over Java in Selenium?

Answer: Few points that favours Python over Java to use with Selenium is,

  • Java programs tend to run slower compared to Python programs.
  • Java uses traditional braces to start and ends blocks, while Python uses indentation.
  • Java employs static typing, while Python is dynamically typed.
  • Python is simpler and more compact compared to Java.

Q58. Other than the default port 4444 how you can run Selenium Server?

Answer: Run Selenium server on java-jar selenium-server.jar-port other than its default port.

Q59.What are the technical limitations while using Selenium RC?

Answer: Apart from “same origin policy” restriction from js, Selenium is also restricted from exercising anything that is outside browser.

Q60. Why to use TestNG with Selenium RC?

Answer: If you want full automation against different server and client platforms, you need a way to invoke the tests from a command line process, reports that tells you what happened and flexibility in how you create your test suites. TestNG gives that flexibility.

Q61. Explain what is framework and what are the frameworks available in RC?

Answer: A collection of libraries and classes is known as Framework and are helpful when testers have to automate test cases. NUnit, JUnit, TestNG, Bromine, RSpec, unittest are some of the frameworks available in RC.

Q62. Explain what is the main difference between web-driver and RC?

Answer: The main difference between Selenium RC and Webdriver is that, selenium RC injects JavaScript function into browsers when the page is loaded. On the other hand, Selenium Webdriver drives the browser using browsers built in support.

Q63. What is the fundamental difference between XPath and CSS selectors?

Answer:The fundamental difference between XPath and CSS selector is – using XPaths we can traverse up in the document i.e. we can move to parent elements. Whereas using the CSS selector, we can only move downwards in the document.

Q64. What if you have written your own element locator and how would you test it?

Answer: To test the locator one can use “Find Button” of Selenium IDE , if you click on it, you would see on screen an element being highlighted provided your element locator is right or or else an error message will be displayed.

Q65. In which format does source view shows your script in Selenium IDE?

Answer: In Selenium IDE source view shows your script in XML format

Q66. Explain how you can debug the tests in Selenium IDE?

Answer:

  • Insert a break point from the location where you want to execute step by step
  • Run the test case
  • At the given break point execution will be paused
  • To continues with the next step click on the Blue button
  • To run commands at a time click on run button

Q67. How you can convert any Selenium IDE tests from Selenese to another language?

Answer: Use the format option of Selenium IDE to convert tests into another programming language.

Q68. In Selenium IDE how you can generate random numbers and dates for test data?

Answer: Generate random numbers by using Java Script type css=input#s javascript{Math.random()} And for type css=input#s javascript{new Date()}

Q69. What are the two modes of views in Selenium IDE?

Answer: Either Selenium IDE can be opened as a pop up window or in side bar

Q70. How can you prepare customized html report using TestNG in hybrid framework?

Answer: The three ways are

  • Junit: With the help of ANT
  • TestNG: Using inbuilt default.html to get the HTML report. Also XST reports from ANT, Selenium, Testng combinations.
  • Using our own customized reports using XSL jar for converting XML content to HTML

Q71. List out different types of locators?

Answer: Different types of locators are

  • By.id()
  • By.name()
  • By.tagName()
  • By.className()
  • By.linkText()
  • By.partialLinkText()
  • By.xpath
  • By.cssSelector()

Q72. How will you use Selenium to upload a file?

Answer: Use “type”command to type in a file input box of upload file. Then, you have to use “Robot” class in JAVA to make file upload work.

Q73. Explain how you can switch between frames?

Answer:To switch between frames webdrivers [ driver.switchTo().frame() ] method takes one of the three possible arguments.

  • A number:  It selects the number by its (zero-based) index
  • A number: A name or ID: Select a frame by its name or ID
  • Previously found WebElement: Using its previously located WebElement select a frame

Q74. Explain how you can find broken images in a page using Selenium Web driver?

Answer: To find the broken images in a page using Selenium web driver is

  • Get XPath and get all the links in the page using tag name
  • In the page click on each and every link
  • Look for 404/500 in the target page title

Q75. Mention what are the capabilities of Selenium WebDriver or Selenium 2.0?

Answer: WebDriver should be used when requiring improvement support for

  • Handling multiple frames, pop ups , multiple browser windows and alerts
  • Page navigation and drag & drop
  • Ajax based UI elements
  • Multi browser testing including improved functionality for browser not well supported by Selenium 1.0

Q76. What is Object Repository?

Answer:An object repository is an essential entity in any UI automations which allows a tester to store all objects that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.

Q77. Explain how to login into any site if it’s showing any authentication popup for password and username?

Answer: Pass the username and password with url

  • Syntax-http://username:password@url
  • ex- http://creyate:tom@www.gmail.com

Q78. How you can use “submit” a form using Selenium?

Answer: You can use “submit” method on element to submit form- element.submit () ;
Alternatively you can use click method on the element which does form submission.

Q79. What is same origin policy? How you can avoid same origin policy?

Answer: The “Same Origin Policy” is introduced for security reason, and it ensures that content of your site will never be accessible by a script from another site.  As per the policy, any code loaded within the browser can only operate within that website’s domain.
To avoid “Same Origin Policy” proxy injection method is used, in proxy injection mode the Selenium Server acts as a client configured HTTP proxy , which sits between the browser and application under test and then masks the AUT under a fictional URL.

Q80. While using click command can you use screen coordinate? 

Answer: To click on specific part of element, you would need to use clickAT command.  ClickAt command accepts element locator and x, y co-ordinates as arguments-
clickAt (locator, cordString)

Q81. What are the limitations of Selenium testing? 

Answer: Unavailability of reliable tech support: Since Selenium is an open-source tool, it does not have dedicated tech support to resolve the user queries. 
Tests web applications only: Selenium needs to be integrated with third-party tools like Appium and TestNG to test desktop and mobile applications.
Limited support for image testing No built-in reporting and test management facility.

Q82. Mention the types of Web locators.

Answer: Locator is a command that tells Selenium IDE which GUI elements ( say Text Box, Buttons, Check Boxes, etc) it needs to operate on. Locators specify the area of action.
  • Locator by ID
  • Locator by the link 
  • Locator by Partial link
  • Locator by Name
  • Locator by TagName
  • Locator by classname
  • Locator by XPath
  • Locator by CSS Selector

Q83. How to click on a hyperlink in Selenium ?

Answer: driver.findElement(By.linkText(“Today’s deals”)).click();
The command finds the element using link text and then clicks on that element, where after the user would be redirected to the corresponding page.
driver.findElement(By.partialLinkText(“Service”)).click();
The above command finds the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element.

Q84. How to retrieve CSS properties of an element?

Answer: getCssValue() method is used to retrieve CSS properties of any web element
Syntax:
  driver.findElement(By.id(“id“)).getCssValue(“name of css attribute”);

Q85. Can Captcha be automated?

Answer: No, Selenium cannot automate Captcha. The concept of Captcha is to ensure that bots and automated programs don’t access sensitive to manually type the captcha while other fields can be filled automatically information - which is why, Selenium cannot automate it. The automation test engineer has. 

Q86. How to upload a file in Selenium WebDriver?

Answer: Use sendkeys() or Robot class method to upload a file. Locate the text box and set the file path using sendkeys() and click on submit button.
Locate the browse button
  WebElement browse =driver.findElement(By.id("uploadfile"));
Pass the path of the file to be uploaded using sendKeys method
    browse.sendKeys("D:\\SeleniumInterview\\UploadFile.txt");

Q87.List out the test types that are supported by Selenium?

Answer: For web based application testing selenium can be used. The test types can be supported are a) Functional, Learn More about Functional Testing. b) Regression For post release validation with continuous integration automation tool could be used a) Jenkins b) Hudson c) Quick Build d) CruiseCont

Q88. Mention what is the use of X-path?

Answer: X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.

Q89. List out the technical challenges with Selenium?

Answer: Technical challenges with Selenium are

  • Selenium supports only web based applications
  • It does not support the Bitmap comparison
  • For any reporting related capabilities have to depend on third party tools
  • No vendor support for tool compared to commercial tools like HP UFT
  • As there is no object repository concept in Selenium, maintainability of objects becomes difficult

Q90. What are the benefits of Automation Testing?

Answer:
  • Aids in testing a large test matrix
  • Enables parallel execution
  • Encourages unattended execution
  • Improves accuracy thereby reducing human-generated errors
  • Saves time and money

Q91. When should I use Selenium IDE?

Answer: Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature makes it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is an ideal tool for a naïve user.

Q92. How to type in a textbox using Selenium?

Answer: The user can use sendKeys(“String to be entered”) to enter the string in the textbox.
Syntax:
WebElement username = drv.findElement(By.id(“Email”));
// entering username
username.sendKeys(“sth”);

Q93. How can we handle web-based pop-up?

Answer: WebDriver offers the users a very efficient way to handle these pop-ups using Alert interface. There are the four methods that we would be using along with the Alert interface.

  • void dismiss() – The dismiss() method clicks on the “Cancel” button as soon as the pop-up window appears.
  • void accept() – The accept() method clicks on the “Ok” button as soon as the pop-up window appears.
  • String getText() – The getText() method returns the text displayed on the alert box.
  • void sendKeys(String stringToSend) – The sendKeys() method enters the specified string pattern into the alert box.

Q94. What is Junit?

Answer: Junit is a unit testing framework introduced by Apache. Junit is based on Java.

Q95. How to handle frame in WebDriver?

Answer:An inline frame acronym as iframe is used to insert another document within the current HTML document or simply a web page into a web page by enabling nesting.
Select iframe by id driver.switchTo().frame(“ID of the frame“); Locating iframe using tagName driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0)); Locating iframe using index frame(index) driver.switchTo().frame(0); frame(Name of Frame) driver.switchTo().frame(“name of the frame”); frame(WebElement element) Select Parent Window driver.switchTo().defaultContent();

Q96. How can we get a text of a web element?

Answer: Get command is used to retrieve the inner text of the specified web element. The command doesn’t require any parameter but returns a string value. It is also one of the extensively used commands for verification of messages, labels, errors etc displayed on the web pages.
Syntax:
String Text = driver.findElement(By.id(“Text”)).getText();

Q97. What is a milestone? What are the types of milestone?

Answer: WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.

  • isDisplayed()
  • isSelected()
  • isEnabled()

Q98. What is an absolute XPath?

Answer:An absolute XPath is a way of locating an element using an XML expression, beginning from the root node i.e. HTML node in the case of web pages.
The main disadvantage of absolute XPath is that even if there is a slight change in the UI or any element then also whole XPath will fail.

Q99. What is the syntax of finding elements by id using CSS Selector?

Answer: By using #idValue in the CSS locator, we can select all the elements belonging to a particular class e.g. ‘#userId’ will select the element having an id – userId.

Q100. WHow can we move to the nth-child element using the CSS selector?

Answer: Using :nth-child(n) in the CSS locator, we can move to the nth child element e.g. div:nth-child(2) will locate 2nd div element of its parent.

WhatsApp-Credo-Systemz