Question 1: What is Selenium?
Answer: Selenium is a robust test automation suite that is used for automating web based applications. It supports multiple browsers, programming languages and platforms.
Question 2: What are different components of selenium?
Answer: Selenium has four components-
- Selenium WebDriver – Selenium WebDriver is used to automate web applications using browser’s native methods.
- Selenium IDE – A firefox plugin that works on record and play back principle.
- Selenium RC – Selenium Remote Control (RC) is officially deprecated by selenium and it used to work on javascript to automate the web applications.
- Selenium Grid – Allows selenium tests to run in parallel across multiple machines.
Question 3: What are some advantages of selenium?
Answer: Following are the advantages of selenium-
- Selenium is open source and free to use without any licensing cost.
- It supports multiple languages like Java, ruby, python etc.
- It supports multi browser testing.
- It has good amount of resources and helping community over the internet.
- Using selenium IDE component, non-programmers can also write automation scripts
- Using selenium grid component, distributed testing can be carried out on remote machines possible.
Question 4: What are some limitations of selenium?
Answer: Following are the limitations of selenium-
- We cannot test desktop application using selenium.
- We cannot test flash based apps using selenium.
- For creating robust scripts in selenium webdriver, programming langauge knowledge is required.
- We have to rely on external libraries and tools forperforming tasks like – logging(log4J), testing framework-(testNG, JUnit), reading from external files(POI for excels) etc.
Question 5: Why do you prefer Selenium Automation Tool?
Answer:
- Free and open source
- Have large user base and helping communities
- Cross browser compatibility
- Platform compatibility
- Multiple programming languages support
Question 6: What is Automation Testing?
Answer: Automation testing is the process of testing the software using an automation tools to find the defects. In this process, executing the test scripts and generating the results are performed automatically by automation tools. Some most popular tools to do automation testing are HP QTP/UFT, Selenium WebDriver, etc.
Question 7: What are the benefits of Automation Testing?
Answer:
- Saves time and money. Automation testing is faster in execution.
- Reusability of code. Create one time and execute multiple times with less or no maintenance.
- Easy reporting. It generates automatic reports after test execution.
- Easy for compatibility testing. It enables parallel execution in combination of different OS and browser environments.
- Low cost maintenance. It is cheaper compared to manual testing in a long run.
- Automated testing is more reliable.
- Automated testing is more powerful and versatile.
- It is mostly used for regression testing. Supports execution of repeated test cases.
- Minimal manual intervention. Test scripts can be run unattended.
- Maximum coverage. It helps to increase the test coverage.
Question 8: What type of tests you have automated?
Answer: Our main focus is to automate test cases to do Regression testing, Smoke testing, and Sanity testing. Sometimes based on the project and the test time estimation, we do focus on End to End testing.
Question 9: How many test cases you have automated per day?
Answer: It depends on Test case scenario complexity and length. I did automate 2-5 test scenarios per day when the complexity is limited. Sometimes just 1 or fewer test scenarios in a day when the complexity is high.
Question 10: Compare Automated Testing & Manual Testing
Answer:
Question 11: Which all browsers are supported by selenium webdriver?
Answer: Some commonly used browsers supported by selenium are-
- Google Chrome – ChromeDriver
- Firefox – FireFoxDriver
- Internet Explorer – InternetExplorerDriver
- Safari – SafariDriver
- HtmlUnit (Headless browser) – HtmlUnitDriver
- Android – Selendroid/Appium
- IOS – ios-driver/Appium
Question 12: What Is WebdriverIO?
Answer. WebdriverIO is a powerful framework for testing mobile and web applications. It uses JavaScript to implement the Selenium Webdriver API and the wire protocol as per the W3C standards. It is available for installation as NPM package and runs on Node.js. Hence, it is also famous with the name as “Selenium 2.0 bindings for NodeJS”.
Question 13: List all the features of WebdriverIO ?
Answer:
- It is a multipurpose automation tool which can fit in to test both the web applications and the native mobile Apps.
- Command execution takes place asynchronously in WebdriverIO. However, we can write them in a synchronous way so to avoid any race conditions that may occur while handling a promise.
- WebdriverIO provides a set of simple JavaScript functions to write tests which are lean, fast and easy to understand.
- It comes with an intelligent Test Runner which optimizes test execution to achieve maximum concurrency. Ideally, it can run all your tests in parallel if adequate CPU/memory resources are present.
- Test runner also adds a feature to register hooks for handling errors and altering test flow based on previous test result. For example, capturing a screenshot when any error occurs or ignoring a set of test cases if a dependent test gets failed.
- It integrates seamlessly with CI tools like Jenkins and utilizes JUnit reporter to debug issues and tracking test execution.
- Services like Sauce Labs and BroweserStack can plugin with WebdriverIO to run tests through the secure tunnel of respective environments.
- Another service for Appium enables testing for mobile devices and eliminates the need to start it manually for test execution.
The primary objective of WebdriverIO is to automate the end to end testing on a large scale. Its test runner helps in building a reliable Test Suite which is easy to understand and manage. It resolves many issues that occur with standard automation libraries. With it, we can organize the tests to run in split mode to enable concurrency. Moreover, it does provide session management and a lot of features to help in debugging runtime issues and find errors in the test cases.
Question 14: What all testing types supported by Selenium WebDriver?
Answer: Selenium Webdriver can be used for performing automated functional and regression testing.
Question 15: What are various ways of locating an element in selenium?
Answer: The different locators in selenium are-
- Id
- XPath
- cssSelector
- className
- tagName
- name
- linkText
- partialLinkText
Question 16: What is an XPath?
Answer: Xpath or XML path is a query language for selecting nodes from XML documents. XPath is one of the locators supported by selenium webdriver.
Question 17: What is an absolute XPath?
Answer: An absolute XPath is a way of locating an element using an XML expression beginning from root node i.e. html node in case of web pages. The main disadvantage of absolute xpath is that even with slightest change in the UI or any element the whole absolute XPath fails.
Example – html/body/div/div[2]/div/div/div/div[1]/div/input
Question 18: What is a relative XPath?
Answer: A relative XPath is a way of locating an element using an XML expression beginning from anywhere in the HTML document. There are different ways of creating relative XPaths which are used for creating robust XPaths (unaffected by changes in other UI elements).
Example – //input[@id=’username’]
Question 19: What is Selenium 2.0 ?
Answer: Web Testing tools Selenium RC and WebDriver are consolidated in single tool in Selenium 2.0. However, latest version of Selenium is 3.0.
Question 20: Mention what is Selenium 3.0?
Answer: Selenium 3.0 is the latest version of Selenium. It has released 2 beta versions of selenium 3.0 with few of the below changes:
A list of few new features added in Selenium 3.0:
Question 21: How will you find an element using Selenium?
Answer: In Selenium every object or control in a web page is referred as an elements, there are different ways to find an element in a web page they are
- ID
- Name
- Tag
- Attribute
- CSS
- Linktext
- PartialLink Text
- Xpath etc
Question 22: 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 b) Regression
Question 23: What are the different network protocols that selenium supports?
Answer: HTTP and HTTPS are the two most commonly used network protocols. And in Selenium, there are multiple ways to handle both of these protocols.
Question 24: How Will You Handle Different Network Protocols In Selenium?
Answer:
Website Not Using Authentication: If a website is only using the HTTP and does not require any authentication, then it’s very easy to handle in Selenium.
WebDriver driver = new ChromeDriver();
driver.get(“http://destination-url/”);
Website Using Basic Authentication: There are many websites which apply basic authentication scheme before allowing access to their home page. Here are three most prominent ways to do it in Selenium.
Below code is using WebDriverWait and Alert classes to implement basic authentication for HTTP.
WebDriverWait testwait = new WebDriverWait(driver, 10);
Alert testalert = testwait.until(ExpectedConditions.alertIsPresent());
testalert.authenticateUsing(new UserAndPassword(**user**, **pass**));
Alternatively, we can also pass the user/pass pair within the HTTP URL as a parameter to the Webdriver’s Get method.
String target = “http://user:pass@host”;
Handle HTTPS Protocol: HTTPS is the secure version of HTTP. And it encrypts all the communication exchanged between the web server and the browser. It makes use of SSL certificates which get downloaded into the browser upon initiating the first request. The certificate contains a public key for encrypting the data flowing from client to the server. Similarly, the server reserves a private key corresponding to the certificate and use it to decrypt the data received. These public/private keys are none other than the famous RSA key-pair and available in different key lengths such as 512, 1024, 2048, and 4096 bits.
So in reality, we need to handle the SSL certificates via Selenium. Also, we’ve to follow different approaches for managing the SSL in Firefox, Chrome, and IE browsers.
Question 25: 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.
Question 26: List out the technical challenges with Selenium?
Answer:
- 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
Question 27. How do I clear content of a text box in Selenium 2.0?
Answer:
WebElement el = driver.findElement(By.id(“ElementID”)); el.clear();
Question 28. How to execute java scripts function.
Answer:
JavascriptExecutor js = (JavascriptExecutor) driver;
String title = (String) js.executeScript(“pass your java scripts”);
Question 29. How to select a drop down value using Selenium2.0?
Answer:
Coming soon
Question 30. How to automate radio button in Selenium 2.0?
Answer:
WebElement el = driver.findElement(By.id(“Radio button id”));
//to perform check operation el.click()
//verfiy to radio button is check it return true if selected else false el.isSelected()
Question 31. What is Selenium 1.0?
Answers :
Selenium 1.0 is popularily known as Selenium Remote Control (Selenium RC). It is a library available in wide variety of languages. The main reason to use Selenium RC was that Selenium IDE was incapable to execute tests in browsers other than Selenium IDE and the limitation of language Selenese used in Selenium IDE.
Question 32. What is Selenium IDE?
Answers :
Selenium IDE is a firefox plug-in. It is used to record and replay tests in firefox browser. It is used only with firefox browser.
Question 33. Why is selenium selected as a test tool?
Answers :
Selenium is used as a testing tool because:
- It is free and open source.
- It has a large user base and helping communities.
- Compatible on different platforms i.e. Windows, Mac OS, Linux etc.
- Have cross browser compatibility (Chrome, Firefox, IE, Safari etc.)
- Support multiple programming languages (Java, C#, Ruby, PERL, Python etc.)
- Support distributed testing.
Question 34. What are selenium supporting testing types?
Answers :
Selenium supports two types of testing:
- Functional Testing
- Regression Testing
Question 35. What are the limitations of selenium?
Answers :
Selenium has following limitations:
- It can be used only to test web based application.
- Mobile applications can not be tested using selenium.
- You can not test captcha and bar code by using selenium.
- The user must have the knowledge of programming language for using selenium.
- Reports can only be generated using third party tools like TestNG or Junit.
Question 36. What is selenese?
Answers :
Selenese is a lanuage which is used for writing test script in selenium IDE.
Question 37. Describe the different types of locators in Selenium?
Answers :
Locator is an address which identifies a web element uniquely within the web page. There are different types of locators in Selenium to identify web elements accurately and precisely. These are:
- ID
- ClassName
- Name
- TagName
- LinkText
- PartialLinkText
- Xpath
- CSS Selector
- DOM
Question 38. What is an Xpath?
Answers :
Xpath is used to locate a web element based on its XML path. It can be used to locate HTML elements.
Question 39. Which is the latest Selenium tool?
Answers :
The latest Selenium tool is WebDriver.
Question 40. What are the different types of Drivers that WebDriver contains?
Answers :
These are the different drivers available in WebDriver:
- FirefoxDriver
- InternetExplorerDriver
- ChromeDriver
- SafariDriver
- OperaDriver
- AndroidDriver
- IPhoneDriver
- HtmlUnitDriver
Question 41. What is Selenium Grid?
Answers :
Selenium Grid facilitates you to distribute your tests on multiple machines and all of them at the same time. So, you can execute tests on Internet Explorer on Windows and Safari on Mac machine using the same text script. It reduces the time of test execution and provides quick feedback.
Question 42. What is the use of xpath?
Answers:
it is used to find the WebElement in web page. It is very useful to identify the dynamic web elements.
Question 43. What are different types of locators?
Answers :
There are 8 types of locators and all are the static methods of the By class.
- By.id(),
- By.name(),
- By.tagName(),
- By.className(),
- By.linkText(),
- By.partialLinkText(),
- By.xpath,
- By.cssSelector().
Question 44. What is the difference between Assert and Verify?
Answers :
Assert– it is used to verify the result. If the test case fail then it will stop the execution of the test case there itself and move the control to other test case.
Verify– it is also used to verify the result. If the test case fail then it will not stop the execution of that test case.
Question 45. What is the alternate way to click on login button?
Answers :
use submit() method but it can be used only when attribute type=submit.
Question 46. How do you verify if the checkbox/radio is checked or not?
Answers :
We can use isSelected() method.
Syntax –
1driver.findElement(By.xpath(“xpath of the checkbox/radio button”)).isSelected();
If the return value of this method is true then it is checked else it is not.
Question 47. How do you handle alert pop-up?
Answers:
To handle alert pop-ups, we need to 1st switch control to alert pop-ups then click on ok or cancle then move control back to main page.
Syntax-
String mainPage = driver.getWindowHandle();
Alert alt = driver.switchTo().alert();// to move control to alert popup
alt.accept();// to click on ok.
alt.dismiss();// to click on cancel.
//Then move the control back to main web page-
driver.switchTo().window(mainPage); → to switch back to main page.
Question 48. How do you launch IE/chrome browser?
Answers:
Before launching IE or Chrome browser we need to set the System property.
//To open IE browser
System.setProperty(“webdriver.ie.driver”,”path of the iedriver.exe file ”);
WebDriver driver = new InternetExplorerDriver();
WebDriver driver = new ChromeDriver();
Question 49. How to perform right click using WebDriver?
Answers:
Use Actions class
Actions act = new Actions(driver);// where driver is WebDriver type
act.moveToElement(webElement).perform();
act.contextClick().perform();
Question 50. How do perform drag and drop using WebDriver?
Answers:
Use Action class
Actions act = new Actions(driver);
WebElement source = driver.findElement(By.xpath(“ —–”)); //source else which you want to drag
WebElement target = driver.findElement(By.xpath(“ —–”)); //target where you want to drop
act.dragAndDrop(source,target).perform();
Question 51. Give the example for method overload in WebDriver.
Answers:
frame(string), frame(int), frame(WebElement).
Question 52. How do you upload a file?
Answers:
To upload a file we can use sendKeys() method. 1driver.findElement(By.xpath(“input field”)).sendKeys(“path of the file which u want to upload”);
Question 53. How do you click on a menu item in a drop down menu?
Answers:
If that menu has been created by using select tag then we can use the methods selectByValue() or selectByIndex() or selectByVisibleText(). These are the methods of the Select class.
If the menu has not been created by using the select tag then we can simply find the xpath of that element and click on that to select.
Question 54. How do you simulate browser back and forward?
Answers:
driver.navigate().back();
driver.navigate().forward();
Question 55. What is selenium webdriver?
Answers:
WebDriver is designed to provide a simpler, more concise programming interface in addition to addressing some limitations in the Selenium-RC API. Selenium-WebDriver was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded. WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.Selenium-WebDriver makes direct calls to the browser using each browser’s native support for automation.
Question 56. How to write the tests in selenium WebDriver?
Answers :
In selenium WebDriver, depending on the programming language, I used different test framework. In C#, I used NUnit, and in Java, I used JUnit. In either programming language, I defined browser webdriver in setup method, and wrote test steps in test method and dispose and close the webdriver in the tear down method.
Question 57. How to configure selenium webdriver in eclipse?
Answers :
In eclipse, I created java projects and added JUnit or TestNG classes. In the project reference, I added JUnit or TestNG jar file. In the test class, I used webdriver in setup, test and teardown methods. Sometimes, I used webdriver in beforeclass, beforemethod, aftermethod, afterclass sections.
Question 58. What are the prerequisites to run selenium webdriver?
Answers :
Depending on the programming language, reference files should be added to the test solutions in C# or test projects in Java. For example, in C#, I added webdriver dlls and in Java, I added Selenium-client-driver.jar file. And also, we should have programming IDE like visual studio or eclipse to run webdriver.
Question 59. What is the difference between selenium 1.0 and webdriver?
Answers :
Selenium 1.0 needs Selenium RC to run a test. However, webdriver can directly launch a browser and run tests.
Question 60. What are the advantages of selenium webdriver?
Answers :
Selenium WebDriver is very flexible to use with Java, .Net, Python, Ruby or html languages. QA engineers who have good coding skills can use it very effectively.
Question 61. What are the disadvantages of selenium webdriver over selenium 1.0?
Answers :
Since selenium web driver requires coding skills, QA engineers should have some knowledge of program development in Java, .Net, or other languages.
Question 62. How to handle multiple windows in selenium webdriver?
Answers:
We can use web driver’s windows handler to identify each window and use switch method to pick the window for test.
Question 63. How to navigate with browser buttons in selenium webdriver?
Answers :
We can use web driver’s back or forward method to simulate browser’s navigation button functionality.
Question 64. Which are the locators used for recognizing the objects in selenium webdriver?
Answers :
In webdriver, we can use element id, name, css, xpath, link text, partial link text and DOM to locate elements.
Question 65. How to run the tests in internet explorer using selenium webdriver?
Answers :
When setup a webdriver in the code, we can select InternetExplorerDriver to use ID. If we want to use of the latest and greatest features of the WebDriver “InternetExplorerDriver”, we need to download Internet Explorer Server.
Question 66. How to run the tests in firefox using selenium webdriver?
Answers :
In the setup method, we select FirefoxDriver for the webDriver.
Question 67. How to run the tests in google chrome using selenium webdriver?
Answers :
Sometimes, webdriver cannot launch chrome directly, so (1) we can use Desired Capabilities of WebDriver, put chrome browser application path in the code; (2) we need to have chromedriver.exe file in the application path. Alternatively, we can manually start chrome driver service, and then launch the test in chrome.
Question 68. How to run the tests without a browser or with HTML unit driver in selenium webdriver?
Answers :
WebDriver driver = new HtmlUnitDriver();
Question 69. How to run Selenium 1.0 tests in webdriver?
Answers :
We can use WebDriverBackedSelenium to run Selenium 1.0 tests in webdriver.
WebDriver driver = new FirefoxDriver();
Selenium selenium = new WebDriverBackedSelenium(driver, “http://www.yoursite.com”);
Question 70. How to convert selenium 1.0 tests to webdriver tests?
Answers :
We can use WebDriverBackedSelenium to run Selenium 1.0 tests in webdriver.
WebDriver driver = new FirefoxDriver();
Selenium selenium = new WebDriverBackedSelenium(driver, “http://www.yoursite.com”);
Question 71. What is webdriver backed selenium?
Answers :
WebDriver backed Selenium is API that enables running Selenium 1.0 tests in web driver.
Question 72. How many browsers are supported by Selenium IDE?
Answers :
Test Engineer can record and playback test with Selenium IDE in Firefox.
Question 73. Can Selenium test an application on iPhone’s Mobile Safari browser?
Answers :
Selenium should be able to handle Mobile Safari browser. There is experimental Selenium IPhone Driver for running tests on Mobile Safari on the iPhone, iPad and iPod Touch.
Question 74. Can Selenium test an application on Android browser?
Answers :
Selenium should be able to handle Android browser. There is experimental Selenium Android Driver for running tests in Android browser.
Question 75. What are the disadvantages of using Selenium as testing tool?
Answers :
Selenium weak points are tricky setup; dreary errors diagnosis; tests only web applications
Question 76. How many browsers are supported by Selenium Remote Control?
Answers :
QA Engineer can use Firefox 7, IE 8, Safari 5 and Opera 11.5 browsers to run actuall tests in Selenium RC.
Question 77. How many programming languages can you use in Selenium RC?
Answers :
Several programming languages are supported by Selenium Remote Control – C# Java Perl PHP Python Ruby
Question 78. How many testing framework can QA Tester use in Selenium RC?
Answers :
Testing frameworks aren’t required, but they can be helpful if QA Tester wants to automate test cases. Selenium RC supports Bromine, JUnit, NUnit, RSpec (Ruby), Test::Unit (Ruby), TestNG (Java), unittest (Python).
Question 79. How to developer Selenium Test Cases?
Answers :
Using the Selenium IDE, QA Tester can record a test to comprehend the syntax of Selenium IDE commands, or to check the basic syntax for a specific type of user interface. Keep in mind that Selenium IDE recorder is not clever as QA Testers want it to be. Quality assurance team should never consider Selenium IDE as a “record, save, and run it” tool, all the time anticipate reworking a recorded test cases to make them maintainable in the future.
Question 80. What programming language is best for writing Selenium tests?
Answers :
The web applications may be written in Java, Ruby, PHP, Python or any other web framework. There are certain advantages for using the same language for writing test cases as application under test. For example, if the team already have the experience with Java, QA Tester could always get the piece of advice while mastering Selenium test cases in Java. Sometimes it is better to choose simpler programming language that will ultimately deliver better success. In this case QA testers can adopt easier programming languages, for example Ruby, much faster comparing with Java, and can become become experts as soon as possible.
Question 81. Have you read any good books on Selenium?
Answers :
There are several great books covering Selenium automation tool, you could check the review at Best Selenium Books: Top Recommended page
Question 82. Do you know any alternative test automation tools for Selenium?
Answers :
Selenium appears to be the mainstream open source tool for browser side testing, but there are many alternatives. Canoo Webtest is a great Selenium alternative and it is probably the fastest automation tool. Another Selenium alternative is Watir, but in order to use Watir QA Tester has to learn Ruby. One more alternative to Selenium is Sahi, but is has confusing interface and small developers community.
Question 83. Compare HP QTP vs Selenium?
Answers :
When QA team considers acquiring test automation to assist in testing, one of the most critical decisions is what technologies or tools to use to automate the testing. The most obvious approach will be to look to the software market and evaluate a few test automation tools. Read Selenium vs QTP comparison
Question 84. Compare Borland Silktest vs Selenium?
Answers :
Check Selenium vs SilkTest comparison
Question 85. How to test Ajax application with Selenium
Answers :
Ajax interview questions could be tough for newbie in the test automation, but will be easily cracked by Selenium Tester with a relevant experience. Read the detailed approach at Testing Ajax applications with Selenium in the right way
Question 86. How can I learn to automate testing using Selenium?
Answers :
Don’t be surprised if the interviewer asks you to describe the approach for learning Selenium. This interviewer wants to hear how you can innovative software test automation process the company. Most likely they are looking for software professional with a good Selenium experience, who can do Selenium training for team members and get the team started with test automation. I hope this Selenium tutorial will be helpful in the preparation for this Selenium interview question.
Question 87. What are the main components of Selenium testing tools?
Answers :
Selenium IDE, Selenium RC and Selenium Grid
Question 88. What is Selenium? What are the different Selenium components?
Answers :
is one of the most popular automated testing suites. Selenium is designed in a way to support and encourage automation testing of functional aspects of web based applications and a wide range of browsers and platforms. Due to its existence in the open source community, it has become one of the most accepted tools amongst the testing professionals.
Selenium is not just a single tool or a utility, rather a package of several testing tools and for the same reason it is referred to as a Suite. Each of these tools is designed to cater different testing and test environment requirements.
The suite package constitutes of the following sets of tools:
- Selenium Integrated Development Environment (IDE) – Selenium IDE is a record and playback tool. It is distributed as a Firefox Plugin.
- Selenium Remote Control (RC) – Selenium RC is a server that allows user to create test scripts in a desired programming language. It also allows executing test scripts within the large spectrum of browsers.
- Selenium WebDriver – WebDriver is a different tool altogether that has various advantages over Selenium RC. WebDriver directly communicates with the web browser and uses its native compatibility to automate.
- Selenium Grid – Selenium Grid is used to distribute your test execution on multiple platforms and environments concurrently.
Question 89. What are the testing types that can be supported by Selenium?
Answers :
Selenium supports the following types of testing:
- Functional Testing
- Regression Testing
Question 90. What are the limitations of Selenium?
Answers :
Following are the limitations of Selenium:
- Selenium supports testing of only web based applications
- Mobile applications cannot be tested using Selenium
- Captcha and Bar code readers cannot be tested using Selenium
- Reports can only be generated using third party tools like TestNG or Junit.
- As Selenium is a free tool, thus there is no ready vendor support though the user can find numerous helping communities.
- User is expected to possess prior programming language knowledge.
Question 91. Explain what is assertion in Selenium and what are the types of assertion?
Answers :
Assertion is used as a verification point. It verifies that the state of the application conforms to what is expected. The types of assertion are “assert”, “verify” and “waifFor”.
Question 92. Mention what is the use of X-path?
Answers :
X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.
Question 93. Explain the difference between single and double slash in X-path?
Answers :
Single slash ‘/ ’
- Single slash (/) start selection from the document node
- It allows you to create ‘absolute’ path expressions
Double Slash ‘// ’
- Double slash (//) start selection matching anywhere in the document
- It enables to create ‘relative’ path expressions
Question 94. List out the technical challenges with Selenium?
Answers :
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
Question 95. What is the difference between type keys and type commands?
Answers :
TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won’t. Type key populates the value attribute using JavaScript whereas .typekeys() emulates like actual user typing
Question 96. What is the difference between verify and assert commands?
Answers :
Assert: Assert allows to check whether an element is on the page or not. The test will stop on the step failed, if the asserted element is not available. In other words, the test will terminated at the point where check fails.
Verify: Verify command will check whether the element is on the page, if it is not then the test will carry on executing. In verification, all the commands are going to run guaranteed even if any of test fails.
Question 97. What is JUnit Annotations and what are different types of annotations which are useful?
Answers :
In JAVA a special form of syntactic meta-data can be added to Java source code, this is know as Annotations. 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
Question 98. While using click command can you use screen coordinate?
Answers :
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)
Question 99. What are the advantages of Selenium?
Answers :
- It supports C#, PHP, Java, Perl, Phython
- It supports 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
Question 100. Why testers should opt for Selenium and not QTP?
Answers :
Selenium is more popular than QTP as
- Selenium is an open source whereas QTP is a commercial tool
- Selenium is used specially for testing web based applications while QTP can be used for testing client server application also
- Selenium supports Firefox, IE, Opera, Safari on operating systems like Windows, Mac, linux etc. however QTP is limited to Internet Explorer on Windows.
- Selenium supports many programming languages like Ruby, Perl, Python whereas QTP supports only VB script PHP, Ruby) to work efficiently with the scripting side of selenium.
Question 101. How to run test case recorded using Selenium IDE in other browsers?
Answer:
Running test case recorded with the help of Selenium -Remote Control.
Question 102. What is the selenium’s recording language?
Answer:
Selenium’s recording language is “HTML”.
Question 103. What are the steps to run automation using selenium?
Answer:
The very basic steps are:
1. Record the test steps using selenium-IDE.
2. Modify the script according to the testing needs. Add validation points, Java Scripts, Time-out etc.
3. Run the test.
4. View the result after test run complete analyze.
Question 104. What are the capabilities of Selenium IDE?
Answer:
Selenium IDE (Integrated Development Environment) works similar to commercial tools like QTP, Silk Test and Test Partner etc.
The below points describes well about Selenium IDE.
1. Selenium IDE is a Firefox add-on.
2. Selenium IDE can support recording the clicks, typing, and other actions to make a test cases.
3. Using Selenium IDE, a tester can play back the test cases in the Firefox browser.
4. Selenium IDE supports exporting the test cases and suites to Selenium RC.
5. Debugging of the test cases with step-by-step can be done.
6. Breakpoint insertion is possible.
7. Page abstraction functionality is supported by Selenium IDE.
8. Selenium IDE can supports an extensibility capability allowing the use of add-ons or user extensions that expand the functionality of Selenium IDE.
Question 105. What is WebDriver?
Answer:
WebDriver is a tool for writing automated tests of websites. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application.
Question 106. So, is it like Selenium? Or Sahi?
Answer:
The aim is the same (to allow you to test your webapp), but the implementation is different.
Rather than running as a Javascript application within the browser (with the limitations this brings, such as the “same origin” problem), WebDriver controls the browser itself. This means that it can take advantage of any facilities offered by the native platform.
Question 107. What is Selenium 2.0?
Answer:
Selenium 2 is the latest version of the Selenium project, and includes the IDE, Server and WebDriver.
Question 108. How do I migrate from using the original Selenium APIs to the new WebDriver APIs?
Answer:
A common question when adopting Selenium 2 is what’s the correct thing to do when adding new tests to an existing set of tests?
Users who are new to the framework can begin by using the new WebDriver APIs for writing their tests. But what of users who already have suites of existing tests? This guide is designed to demonstrate how to migrate your existing tests to the new APIs, allowing all new tests to be written using the new features offered by WebDriver.
Question 109. Which browsers does WebDriver support?
Answer:
The existing drivers are the ChromeDriver, InternetExplorerDriver, FirefoxDriver, OperaDriver and HtmlUnitDriver. For more information about each of these, including their relative strengths and weaknesses, please follow the links to the relevant pages. There is also support for mobile testing via the AndroidDriver, OperaMobileDriver and IPhoneDriver.
Question 110. What does it mean to be “developer focused”?
Answer:
We believe that within a software application’s development team, the people who are best placed to build the tools that everyone else can use are the developers. Although it should be easy to use WebDriver directly, it should also be easy to use it as a building block for more sophisticated tools. Because of this, WebDriver has a small API that’s easy to explore by hitting the “autocomplete” button in your favourite IDE, and aims to work consistently no matter which browser implementation you use.
Question 111. How do I execute Javascript directly?
Answer:
We believe that most of the time there is a requirement to execute Javascript there is a failing in the tool being used: it hasn’t emitted the correct events, has not interacted with a page correctly, or has failed to react when an XmlHttpRequest returns. We would rather fix WebDriver to work consistently and correctly than rely on testers working out which Javascript method to call. We also realise that there will be times when this is a limitation. As a result, for those browsers that support it, you can execute Javascript by casting the WebDriver instance to a JavascriptExecutor. In Java, this looks like:
WebDriver driver;// Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(“return document.title”);
Other language bindings will follow a similar approach. Take a look at the UsingJavascript page for more information.
Question 112. Why is my Javascript execution always returning null?
Answer:
You need to return from your javascript snippet to return a value, so: js.executeScript(“document.title”);
will return null, but:
js.executeScript(“return document.title”);
will return the title of the document.
Question 113. Can you tell me the syntax to open/launch Firefox browser In WebDriver software testing tool?
Answer:
We can open new Mozilla Firefox browser Instance using bellow given syntax In WebDriver software testing tool.
WebDriver driver = new FirefoxDriver();
VIEW PRACTICAL example.
Question 114. What Is XPath and what Is use of It In WebDriver?
Answer:
In Selenium WebDriver software testing tool, XPath is used to locate the elements. Using XPath, We can navigate through elements and attributes In an XML document to locate software webpage elements like buttons, text box, links, Images etc..
Question 115. Which tool you are using to find the XPath of any element?
Answer:
I am using Mozilla Firefox AddOns FireBug and FirePath to find the XPath of software web elements. see THIS POST to download it.
Question 116. What is the difference between absolute XPath and relative XPath?
Answer:
Absolute XPath: Absolute XPath Is the full path starting from root node and ends with desired descendant element’s node. It will start using single forward slash(/) as bellow.
Example Of Absolute XPath:
/ html/body/div[3]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div/div/div[1]/div/div/ div/div[1]/div[2]/form/table/tbody/tr[1]/td/input
Above XPath Is absolute XPath of calc result box given on THIS PAGE. It starts top node html and ends with input node.
Relative XPath: Instead of starting from root node, Relative XPath starts from any In between node or current element’s node(last node of element). It will start using double forward slash(//) as below.
Example Of Relative XPath:
//input[@id=’Resultbox’]
Above XPath Is relative XPath of same calc result box given on THIS PAGE.
Question 117. How To Handle Dynamic Changing IDs In XPath. Example: //div[@id=’post-body-3647323225296998740′]/div[1]/form[1]/input[1] In this XPath “3647323225296998740” Is changing every time when reloading the page. How to handle this situation?
Answer:
There are many different alternatives In such case.
Alternative 1: Look for any other attribute which Is not changing every time In that div node like name, class etc. So If this div node has class attribute then we can write xpath as bellow.
//div[@class=’post-body entry-content’]/div[1]/form[1]/input[1]
Alternative 2: You can use absolute xpath(full xpath) where you not need to give any attribute names In xpath.
/ html/body/div[3]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div/div/div[1]/div/div/ div/div[1]/div[2]/div[1]/form[1]/input[1]
Alternative 3: Use starts-with function. In this xpath’s ID attribute, “post-body-” part remain same every time. So you can use xpath as bellow.
//div[starts-with(@id,’post-body-‘)]/div[1]/form[1]/input[1]
Alternative 4: Use contains function. Same way you can use contains function as bellow.
div[contains(@id,’post-body-‘)]/div[1]/form[1]/input[1]
Question 118. How to press ENTER key button on text box In selenium webdriver?
Answer:
To press ENTER key using selenium WebDriver software automation tool, We need to use selenium Enum Keys with Its constant ENTER as bellow.
driver.findElement(By.xpath(“//input[@id=’gbqfq’]”)).sendKeys(Keys.ENTER);
Question 119. How many types of waits available In selenium WebDriver?
Answer:
There are two types of waits available In selenium WebDriver software automation testing tool.
1. Implicit Wait
2. Explicit Wait
Question 120. What Is Implicit Wait In Selenium WebDriver?
Answer:
Sometimes, Elements are taking time to be appear on software web application page. Using Implicit wait In webdriver software testing test case, We can poll the DOM for certain amount of time when some element or elements are not available Immediately on webpage.
Implicit Wait Example:
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
If you will write above syntax In your test, Your WebDriver test will wait 10 seconds for appearing element on page.
Question 121. What Is Explicit Wait In Selenium WebDriver?
Answer:
Using explicit wait code In selenium webdriver software automation testing tool, You can define to wait for a certain condition to occur before proceeding further test code execution.
Explicit Wait Example:
WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.elementToBeClickable(By.xpath(“//input[@id=’gbqfq’]”)));
Above code will wait for 20 seconds for targeted element to be displayed and enabled or we can say clickable.
Question 122. I wants to pause my test execution for fix 10 seconds at specific point. How can I do It?
Answer:
You can use java.lang.Thread.sleep(long milliseconds) method to pause the software test execution for specific time. If you wants to pause your test execution for 10 seconds then you can use bellow given syntax In your test.
Thread.sleep(10000);
Question 123. How to count total number of rows of a table using Selenium 2.0?
Answer:
List {WebElement} rows = driver.findElements(By.className(“//table[@id=’tableID’]/tr”));
int totalRow = rows.size();
Question 124. How to capture page title using Selenium 2.0?
Answer:
String title = driver.getTitle()
Question 125. How to store page source using Selenium 2.0?
Answer:
String pagesource = driver.getPageSource().
Question 126. How to store current url using selenium 2.0?
Answer:
String currentURL = driver.getCurrentUrl()
Question 127. How to assert text assert text of webpage using selenium 2.0?
Answer:
WebElement el = driver.findElement(By.id(“ElementID”));
//get test from element and stored in text variable
String text = el.getText();
//assert text from expected
Assert.assertEquals(“Element Text”, text);
Question 128. How to get element attribute using Selenium 2.0?
Answer:
WebElement el = driver.findElement(By.id(“ElementID”));
//get test from element and stored in text variable
String attributeValue = el. getAttribute(“AttributeName”);
Question 129. How to double click on element using selenium 2.0?
Answer:
WebElement el = driver.findElement(By.id(“ElementID”));
Actions builder = new Actions(driver);
builder.doubleClick(el).build().perform();
Question 130. How to perform drag and drop in selenium 2.0?
Answer:
WebElement source = driver.findElement(By.id(“Source ElementID”));
WebElement destination = driver.findElement(By.id(“Taget ElementID”));
Actions builder = new Actions(driver);
builder.dragAndDrop(source, destination ).perform();
Question 131. How to maximize window using selenium 2.0?
Answer:
driver.manage().window().maximize();
Question 132. What is selenium 2.0?
Answers :
Selenium 2.0 is a tool which is a combination of web testing tools Selenium RC and WebDriver.
Question 133. Where the result is seen of Test Execution in Selenium IDE?
Answers :
The result of test execution is displayed in a Log Window in Selenium IDE.
Question 134. Can you edit tests in Selenium IDE?
Answers :
Yes, tests in Selenium IDE can be edited. There are two ways to edit tests in Selenium IDE.
- By Table views
- Looking into the source code
Question 135. Can you use html id and name while using Selenium IDE?
Answers :
Yes, You can use html id and name as it is available in Selenium IDE.
Question 136. What are the WebDriver supported Mobile Testing Drivers?
Answers :
WebDriver supported “mobile testing drivers” are:
- AndroidDriver
- IphoneDriver
- OperaMobileDriver
Question 137. What are the popular programming languages supported by Selenium WebDriver to write Test Cases?
Answer :
- JAVA
- PHP
- Python
- C#
- Ruby
- Perl
Question 138. What is the difference between assert and verify commands?
Answer :
Assert: Assert command checks if the given condition is true or false. If the condition is true, the program control will execute the next phase of testing, and if the condition is false, execution will stop and nothing will be executed.
Verify: Verify command also checks if the given condition is true or false. It doesn’t halts program execution i.e. any failure during verification would not stop the execution and all the test phases would be executed.
Question 139. What is the difference between”/” and”//” in Xpath?
Answer:
Single Slash”/”: Single slash is used to create Xpath with absolute path.
Double Slash”//”: Double slash is used to create Xpath with relative path.
Question 140. What is the command line we have to write inside a .bat file to execute a selenium project when we are using testng?
Answer:
java -cp bin;jars/* org.testng.TestNG testng.xml
Question 141. Which is the package which is to be imported while working with WebDriver?
Answer:
org.openqa.selenium
Question 142. How to check if an element is visible on the web page?
Answer:
use isDisplayed() method. The return type of the method is boolean. So if it return true then element is visible else not visible.
1 driver.findElement(By.xpath(“xpath of elemnt”)).isDisplayed();
Question 143. How to check if a button is enabled on the page?
Answer:
Use isEnabled() method. The return type of the method is boolean. So if it return true then button is enabled else not enabled.
1 driver.findElement(By.xpath(“xpath of button”)).isEnabled();
Question 144. How to check if a text is highlighted on the page?
Answer:
To identify weather color for a field is different or not-
String color = driver.findElement(By.xpath(“//a[text()=’Shop’]”)).getCssValue(“color”);
String backcolor = driver.findElement(By.xpath(“//a[text()=’Shop’]”)).getCssValue(“background-color”);
System.out.println(color);
System.out.println(backcolor);
Here if both color and back color different then that means that element is in different color.
Question 145. How to check the checkbox or radio button is selected?
Answer:
Use isSelected() method to identify. The return type of the method is boolean. So if it return true then button is selected else not enabled.
1 driver.findElement(By.xpath(“xpath of button”)).isSelected();
Question 146. How to get the title of the page?
Answer:
Use getTitle() method.
1 Syntax- driver.getTitle();
Question 147. How do u get the width of the textbox?
Answer:
1 driver.findElement(By.xpath(“xpath of textbox ”)).getSize().getWidth();
2
3 driver.findElement(By.xpath(“xpath of textbox ”)).getSize().getHeight();
Question 148. How do u get the attribute of the web element?
Answer:
driver.getElement(By.tagName(“img”)).getAttribute(“src”) will give you the src attribute of this tag. Similarly, you can get the values of attributes such as title, alt etc.
Similarly you can get CSS properties of any tag by using getCssValue(“some propety name”).
Question 149. How to check whether a text is underlined or not?
Answer:
Identify by getCssValue(“border-bottom”) or sometime getCssValue(“text-decoration”) method if the cssValue is ‘underline’ for that WebElement or not.
ex- This is for when moving cursor over element that is going to be underlined or not-
public class UnderLine {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(“https://www.google.co.in/? gfe_rd=ctrl&ei=bXAwU8jYN4W6iAf8zIDgDA&gws_rd=cr”);
String cssValue= driver.findElement(By.xpath(“//a[text()=’Hindi’]”)).getCssValue(“text-decoration”);
System.out.println(“value”+cssValue);
Actions act = new Actions(driver); act.moveToElement(driver.findElement(By.xpath(“//a[text()=’Hindi’]”))).perform();
String cssValue1= driver.findElement(By.xpath(“//a[text()=’Hindi’]”)).getCssValue(“text-decoration”);
System.out.println(“value over”+cssValue1);
driver.close();
}
}
Question 150. How to change the URL on a webpage using selenium web driver?
Answer:
1 driver.get(“url1”);
2
3 driver.get(“url2”);
Question 151. How to hover the mouse on an element?
Answer:
Actions act = new Actions(driver);
act.moveToElement(webelement); //webelement on which you want to move cursor
Question 152. What is the use of getOptions() method?
Answer:
getOptions() is used to get the selected option from the dropdown list.
Question 153. What is the use of deSelectAll() method?
Answer:
It is used to deselect all the options which have been selected from the dropdown list.
Question154. Is WebElement an interface or a class?
Answer:
WebDriver is an Interface.
Question 155. FirefoxDriver is class or an interface and from where is it inherited?
Answer:
FirefoxDriver is a class. It implements all the methods of WebDriver interface.
Question 156. Which is the super interface of webdriver?
Answer:
SearchContext.
Question 157.What is the difference b/w close() and quit()?
Answer:
close() – it will close the browser where the control is.
quit() – it will close all the browsers opened by WebDriver.
Question 158. Can we enter text without using sendKeys()?
Answer:
Yes we can enter text without using sendKeys() method. We have to use combination of javascript and wrapper classes with WebDriver extension class, check the below code-
public static void setAttribute(WebElement element, String attributeName, String value)
{
WrapsDriver wrappedElement = (WrapsDriver) element;
JavascriptExecutor driver = (JavascriptExecutor)wrappedElement.getWrappedDriver();
driver.executeScript(“arguments[0].setAttribute(arguments[1],arguments[2])”, element, attributeName, value);
}
call the above method in the test script and pass the text field attribute and pass the text you want to enter.
Question 159. There is a scenario whenever “Assert.assertEquals()” function fails automatically it has to take screenshot. How can you achieve this?
Answer:
By using EventFiringWebDriver.
Syntax-EventFiringWebDriver eDriver=new EventFiringWebDriver(driver);
File srcFile = eDriver.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File(imgPath));
Question 160. What is Automation Testing?
Answers :
Automation testing or Test Automation is a process of automating the manual process to test the application/system under test. Automation testing involves use to a separate testing tool which lets you create test scripts which can be executed repeatedly and doesn’t require any manual intervention.
Question 161. What are the benefits of Automation Testing?
Answers :
Benefits of Automation testing are:
1. Supports execution of repeated test cases
2. Aids in testing a large test matrix
3. Enables parallel execution
4. Encourages unattended execution
5. Improves accuracy thereby reducing human generated errors
6. Saves time and money
Question 162. Why should Selenium be selected as a test tool?
Answers :
Selenium
- is free and open source
- have a large user base and helping communities
- have cross Browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.)
- have great platform compatibility (Windows, Mac OS, Linux etc.)
- supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
- has fresh and regular repository developments
- supports distributed testing
Question 163. When to use web driver backed selenium?
Answers :
When we have existing tests in Selenium 1.0 (RC), if we want to avoid using Selenium RC, instead we want to use web driver, we need to use web driver backed selenium.
Question 164. Which version of selenium IDE supports webdriver?
Answers :
Any version higher than 2.0 supports webdriver.
Question 165. How to invoke an application in webdriver?
Answers :
We can use Process to invoke application in the code using web driver.
Question 166. Which of Selenium IDE commands not supported in webdriver?
Answers :
It depends on the format of conversion functionality of Selenium IDE to web driver. sometimes, not all IDE script can be converted to web driver without any problem.
Question 167. Where to download selenium webdriver?
Answers :
Selenium WebDriver libraries can be download from http://www.seleniumhq.org website.
Question 168. What is implicit and explicit wait in selenium webdriver?
Answers :
Explicit wait:
An explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code. The worst case of this is Thread.sleep(), which sets the condition to an exact time period to wait. There are some convenience methods provided that help you write code that will wait only as long as required. WebDriverWait in combination with ExpectedCondition is one way this can be accomplished.
Implicit wait:
An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.
Question 169. What is the difference between an assert and a verify with Selenium commands?
Answer: Coming soon
Question 170. What Selenese commands can be used to help debug a regexp?
Answers :
Text Pattern matching commands can be used to help debug a regex. For example, Verify Title regexp:*.Film will match any text with *.Film pattern.
Question 171. What is one big difference between SilkTest and Selenium, excluding the price?
Answers :
Silk Test is a test automation solution for development, quality and business teams who need to deliver software faster.
With Silk Test you can create and execute tests across multiple platforms and devices to ensure that your applications work exactly as intended.
In Selenium, we create tests with Selenium IDE and run it with multiple platforms by using web driver.
Question 172. Which browsers can Selenium IDE be run in?
Answers :
Selenium IDE is firefox ad on, so it runs on Firefox browser.
Question 173. If a Selenium function requires a script argument, what would that argument look like in general terms?
Answers :
That should be java script argument.
Question 174. If a Selenium function requires a pattern argument, what five prefixes might that argument have?
Answers:
* which translates to “match anything,” i.e., nothing, a single character, or many characters.
[] (character class) which translates to “match any single character found inside the square brackets.” A dash (hyphen) can be used as a shorthand to specify a range of characters (which are contiguous in the ASCII character set). A few examples will make the functionality of a character class clear:
[aeiou] matches any lowercase vowel
[0-9] matches any digit
[a-zA-Z0-9] matches any alphanumeric character
Question 175. What is the regular expression sequence that loosely translates to “anything or nothing?”
Answers :
* which translates to “match anything,” i.e., nothing, a single character, or many characters.
Question 176. What is the globbing sequence that loosely translates to “anything or nothing?
Answers :
glob: label
Question 177. What does a character class for all alphabetic characters and digits look like in regular expressions?
Answers :
[a-zA-Z0-9] matches any alphanumeric character
Question 178. What does a character class for all alphabetic characters and digits look like in globbing?
Answers :
regexp: *[a-zA-Z0-9]
Question 179. What must one set within SIDE in order to run a test from the beginning to a certain point within the test?
Answers :
We need to set a break point in the test, so the test will pause at the break point.
Question 180. What does a right-pointing green triangle at the beginning of a command in SIDE indicate?
Answers :
That triangle indicates that test paused at that step, or will start from that step.
Question 181. How does one get rid of the right-pointing green triangle?
Answers :
Right click on that line and remove break point.
Question 182. How can one add vertical white space between sections of a single test?
Answers :
User can input comment line between test steps, and in the comment line, add spaces.
Question 183. What Selenium functionality uses wildcards?
Answers :
Regular expression can use wildcards.
Question 184 Which wildcards does SIDE support?
Answers :
*,?,:
Question 185. What are the main types of regular expression quantifiers you know?
Answers:
* which translates to “match anything,” i.e., nothing, a single character, or many characters.
[] (character class) which translates to “match any single character found inside the square brackets.” A dash (hyphen) can be used as a shorthand to specify a range of characters (which are contiguous in the ASCII character set). A few examples will make the functionality of a character class clear:
[aeiou] matches any lowercase vowel
[0-9] matches any digit
[a-zA-Z0-9] matches any alphanumeric character
Question 186. What regular expression special character(s) means “any character?”
Answers :
* symbol means any character
Question 187. What distinguishes between an absolute and relative URL in SIDE?
Answers :
Absolute URL means the URL starts with http or https. Selenium IDE addes the argument in the open statement and create an absolute URL Relative URL means that in BaseURL, we can put the main domain, and in the open statment, user should put relative URL;
For example, if main url is http://mysite.com, in the relative url, we can put http://beta.mysite.com in the open statement.
Question 188. How would one access a Selenium variable named “count” from within a JavaScript snippet?
Answers:
${count}
Question 189. What Selenese command can be used to display the value of a variable in the log file, which can be very valuable for debugging?
Answers :
We can use echo command to log information in the test result output.
Question 190. If one wanted to display the value of a variable named answer in the log file, what would the first argument to the previous command look like?
Answers :
echo ${variableName}
Question 191. Where did the name “Selenium” come from?
Answers :
Actually, Selenium is a chemical element name. But Thoughtworks used it for test automation framework api.
Question 192. Which Selenium command(s) simulates selecting a link?
Answers :
Selenium has several commands to verify links. For simulating selecting a link, we can use findElement(By.Link(“LinkName”))
Question 193. Which two commands can be used to check that an alert with a particular message popped up?
Answers :
Use command VerifyAlertPresent
Question 194. What does a comment look like in Column view?
Answers :
Comments display in pink color
Question 195. What does a comment look like in Source view?
Answers :
<!–This is second comment–>
<!–This is a comment–>
Question 196. What are Selenium tests normally named (as displayed at the top of each test when viewed from within a browser)?
Answers :
In the browser, the test name in Selenium IDE will be displayed.
Question 197. What command simulates selecting the browser’s Back button?
Answers :
goBack command
Question 198. If the Test Case frame contains several test cases, how can one execute just the selected one of those test cases?
Answers :
Users can use “Play current test case” function of Selenium IDE
Question 199. What globbing functionality is NOT supported by SIDE?
Answers:
Globbing supports * or?, so other patterns are not supported by globbing. We need to use Regular Expressions for that.
Question 200. What is wrong with this character class range? [A-z]
Answers:
It should be [a-z]; A should be written as lower case.
Question 201. What are three ways of specifying an uppercase or lowercase M in a Selenese pattern?
Answers :
We can use globbing, regular expression, and exact.
Uppercase: [A-Z]
Lowercase: [a-z]
Question 202. What does this regular expression match? regexp:[1-9][0-9],[0-9]{3},[0-9]{4}
Answers:
If we use the number 1 match: 11,111,1111
Question 203. What are two ways to match an asterisk within a Selenese regexp?
Answers :
* or any symbol with *
Question 204. What is the generic name for an argument (to a Selenese command) which starts with//?
Answers :
Xpath
Question 205. What Selenese command is used to choose an item from a list?
Answers :
Select command
Question 206. How many matches exist for this pattern? regexp:[13579][02468]
Answers :
25 (basically, any odd number from this group [13579] and any even number from this [02468])
Question 207. What is the command associated with testing an alert?
Answers :
AssertAlert,AssertAlertNoPresent
Question 208 How can one get SIDE to always record an absolute URL for the open command’s argument?
Answers :
In the Selenium IDE options, check “Record Absolute URL” option.
Question 209. What Selenese command and argument can be used to transfer the value of a JavaScript variable into a SIDE variable?
Answers :
Use “store” command
Question 210. How would one access the value of a SIDE variable named name from within a JavaScript snippet used as the argument to a Selenese command?
Answers :
${variableName}
Question 211. Which is the only browser in which Selenium IDE can be used?
A)Safari
B)Firefox
C)GoogleChrome
D)Internet Explorer
Answer: Firefox
Question 212. Selenium supports which kinds of applications?
A) Web Based applications
B)Stand alone applications
C)Both
D)None of the above
Answer: Web Based Applications
Question 213. Find the type of text pattern used in Selenium
A) Chronological Sequence
B) Globbing
C) Simulation
D)None of the above
Answer: Globbing
Question 214. Which of the following command is a “Onevent Handler”
A) focus()
B) assertAlert()
C) fireEvent()
D) alert()
Answer: fireEvent()
Question 215. Selenium server is developed in
A)Perl
B) Java
C) Python
D).Net
Answer: Java
Question 216. Which Driver implementation will allow headless mode
A) FireFoxDriver()
B) HtmlUnitDriver()
C)SafariDriver
D) ChromeDriver
Answer: HTMLUnitDriver
Question 217. What is Selenium IDE?
Answers :
Selenium IDE is for building Selenium test cases. It operates as a Mozilla Firefox add on and provides an easy to use interface for developing and running individual test cases or entire test suites. Selenium-IDE has a recording feature, which will keep account of user actions as they are performed and store them as a reusable script to play back.
Question 218. What is the use of context menu in Selenium IDE?
Answers :
It allows the user to pick from a list of assertions and verifications for the selected location.
Question 219. Can tests recorded using Selenium IDE be run in other browsers?
Answers :
Yes. Although Selenium IDE is a Firefox add on, however, tests created in it can also be run in other browsers by using Selenium RC (Selenium Remote Control) and specifying the name of the test suite in command line.
Question 220. What are the advantage and features of Selenium IDE?
Answers :
- Intelligent field selection will use IDs, names, or XPath as needed
- It is a record & playback tool and the script format can be written in various languages including C#, Java, PERL, Python, PHP, HTML
- Auto complete for all common Selenium commands
- Debug and set breakpoints
- Option to automatically assert the title of every page
- Support for Selenium user-extensions.js file
Question 221. What are the disadvantage of Selenium IDE tool?
Answers :
- Selenium IDE tool can only be used in Mozilla Firefox browser.
- It is not playing multiple windows when we record it.
Question 222. What is Selenium RC (Remote Control)?
Answers :
Selenium RC allows the test automation expert to use a programming language for maximum flexibility and extensibility in developing test logic.
For example, if the application under test returns a result set and the automated test program needs to run tests on each element in the result set, the iteration/ loop support of programming language’s can be used to iterate through the result set, calling Selenium commands to run tests on each item. Selenium RC provides an API and library for each of its supported languages. This ability to use Selenium RC with a high level programming language to develop test cases also allows the automated testing to be integrated with the project’s automated build environment.
Question 223. What is Selenium Grid?
Answers :
Selenium Grid in the selenium testing suit allows the Selenium RC solution to scale for test suites that must be run in multiple environments. Selenium Grid can be used to run multiple instances of Selenium RC on various operating system and browser configurations.
Question 224. How Selenium Grid works?
Answers :
Selenium Grid sent the tests to the hub. Then tests are redirected to an available Selenium RC, which launch the browser and run the test. Thus, it allows for running tests in parallel with the entire test suite.
Question 225. What you say about the flexibility of Selenium test suite?
Answers :
Selenium testing suite is highly flexible. There are multiple ways to add functionality to Selenium framework to customize test automation. As compared to other test automation tools, it is Selenium’s strongest characteristic. Selenium Remote Control support for multiple programming and scripting languages allows the test automation engineer to build any logic they need into their automated testing and to use a preferred programming or scripting language of one’s choice. Also, the Selenium testing suite is an open source project where code can be modified and enhancements can be submitted for contribution.
Question 226. What test can Selenium do?
Answers :
Selenium is basically used for the functional testing of web based applications. It can be used for testing in the continuous integration environment. It is also useful for agile testing
Question 227. What is the cost of Selenium test suite?
Answers :
Selenium test suite a set of open source software tool, it is free of cost.
Question 228.What browsers are supported by Selenium Remote Control?
Answers :
The test automation expert can use Firefox, IE 7/8, Safari and Opera browsers to run tests in Selenium Remote Control.
Question 229. What programming languages can you use in Selenium RC?
Answers :
C#, Java, Perl, PHP, Python, Ruby
Question 230. What are the advantages and disadvantages of using Selenium as testing tool?
Answers :
Advantages: Free, Simple and powerful DOM (document object model) level testing, can be used for continuous integration; great fit with Agile projects.
Disadvantages: Tricky setup; dreary errors diagnosis; can not test client server applications.
Question 231. What is difference between QTP and Selenium?
Answers :
Only web applications can be testing using Selenium testing suite. However, QTP can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer,
Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, QTP is limited to Internet Explorer on Windows.
QTP uses scripting language implemented on top of VB Script. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.
Question 232. What is difference between Borland Silk test and Selenium?
Answers :
Selenium is completely free test automation tool, while Silk Test is not. Only web applications can be testing using Selenium testing suite. However, Silk Test can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, Silk Test is limited to Internet Explorer and Firefox.
Silk Test uses 4Test scripting language. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.
Question 233. What is the difference between an assert and a verify with Selenium commands?
Answers :
Effectively an “assert” will fail the test and abort the current test case, whereas a “verify” will fail the test and continue to run the test case.
Question 234. If a Selenium function requires a script argument, what would that argument look like in general terms?
Answers :
StoreEval(script, variable) and storeExpression(expression, variableName)
Question 235. If a Selenium function requires a pattern argument, what five prefixes might that argument have?
Answers :
glob, regexp, exact, regexpi
Question 236. What is the regular expression sequence that loosely translates to “anything or nothing?”
Answers :
(.* i.e., dot star) This two-character sequence can be translated as “0 or more occurrences of any character” or more simply, “anything or nothing.
Question 237. What is the globbing sequence that loosely translates to “anything or nothing?
Answers :
(*) which translates to “match anything,” i.e., nothing, a single character, or many characters.
Question 238. What does a character class for all alphabetic characters and digits look like in regular expressions?
Answers :
[0-9] matches any digit
[A-Za-z0-9] matches any alphanumeric character
[A-Za-z] matches any alphabet character
Question 239. What does a character class for all alphabetic characters and digits look like in globbing?
Answers :
[0-9] matches any digit
[a-zA-Z0-9] matches any alphanumeric character
[a-zA-Z] matches any alphabet character
Question 240. What must one set within SIDE in order to run a test from the beginning to a certain point within the test?
Answers :
Set Toggle BreakPoint.
Question 241. What does a right-pointing green triangle at the beginning of a command in SIDE indicate?
Answers :
Play Entire Test Suite
Question 242. Which wildcards does SIDE support?
Answers :
*, []
Question 243. What are the four types of regular expression quantifiers which we’ve studied?
Answers:
* quantifier: 0 or more of the preceding character (or group)
+ quantifier: 1 or more of the preceding character (or group)
? quantifier: 0 or 1 of the preceding character (or group)
{1,5} quantifier: 1 through 5 of the preceding character (or group)
Question 244. What regular expression special character(s) means “any character?”
Answers :
(.*)
Question 245. What distinguishes between an absolute and relative URL in SIDE?
Answers :
Absolute URL: Its is base url and this represent domain address. Relative URL: (Absolute URL + Page Path). Open command uses Base URL (Absolute URL) to navigate web page.
Question 246. How would one access a Selenium variable named “count” from within a JavaScript snippet?
Answers :
${count}
Question 247. What Selenese command can be used to display the value of a variable in the log file, which can be very valuable for debugging?
Answers :
echo()
Question 248. If one wanted to display the value of a variable named answer in the log file, what would the first argument to the previous command look like?
Answers :
echo()
Question 249. Which Selenium command(s) simulates selecting a link?
Answers :
click, clickandWait, ClickAt, ClickAtandWait, DoubleClick, DoubleClickandWait, doubleClickAt, doubleClickAtandWait
Question 250. Which two commands can be used to check that an alert with a particular message popped up?
Answers :
The following commands are available within Selenium for processing Alerts:
- getAlert()
- assertAlert()
- assertAlertNotPresent()
- assertAlertPresent()
- storeAlert()
- storeAlertPresent()
- verifyAlert()
- verifyAlertNotPresent()
- verifyAlertPresent()
- waitForAlert()
- waitForAlertNotPresent()
- waitForAlertPresent()
The AlertPresent() and AlertNotPresent() functions check for the existence or not of an alert – regardless of it’s content. The Alert() functions allow the caller to specify a pattern which should be matched. The getAlert() method also exists in Selenium RC, and returns the text from the previous Alert displayed.
Question 251. How do you open/start selenium-ide after installation?
Answers:
First launch/open firefox browser and then click on ‘Tools’ tab in the menu bar.. You can see an option called ‘selenium ide’, click on it, a small window will be opened where you can start recording scripts…
Question 252. Features of selenium IDE..
Answers:
- Its main feature is record and playback..
- Debugging features by setting breakpoints, startpoints, pause..
- Identifies element using id, name, xpath etc..
- Auto complete for all common selenium commands..
- It has an option of asserting title of every page automatically..
- Support for selenium user-extensions.js file..
- Option to run single test or multiple tests(suite).
- It has a feature of exporting testcase/suite into different formats like C#, Java, Ruby, Python..
Question 253. Advantages and disadvantages of selenium IDE.
Answers:
Advantages:
- Freeware..
- Easy to install..
- It is the only flavor of selenium that allows us to record user actions on browser window..
- Scripts recorded in IDE can be coverted into other languages like Java, C#, Python and Ruby..
- It is not only a time saver but also an excellent way of learning scripts syntax..
- We can insert comments in the middle of the script for better understanding and debugging.. · Context menu, which allows us to pick from a list of assertions and verifications for the selec
- ted location..
Disadvantages:
- Main disadvantage of IDE is that it runs only in firefox browser..
- Selenium IDE can execute scripts created in selenese only
- Cannot upload files.. · It does not directly support loops and conditions..
- Reading from external files like .txt, .xls is not possible..
Question 254. What are the selenium locators and what is the tool you use to identify element?
Answer:
Selenium locators are the way of finding HTML element on the page to perform Selenium actions… We usefirebug(for firefox) to identify elements as it is more popular and powerful web development tool.. It inspects HTML and modify style and layout in real-time.. We can edit, debug and monitor CSS, HTML and Javascript live in any web page..
–>For Internet Explorer we can choose debugbar.. It views HTML DOM tree, we can view and edit tab attributes..
Question 255. How do you locate elements in IDE?
Answer:
I will focus on the unique attribute values like id, name or other structural information that is stable enough to withstand frequent changes to the web application.. I strongly recommend CSS selectors as locating strategy.. They are considerably faster than xpath and can find the most complicated objects in any HTML document.
Question 256. What is selenese?
Answer:
Selenium set of commands that run our test is called Selenese. A sequence of these commands is a test script. There are three types of selenese.
1. Actions: They perform some operations like clicking a link or typing text in text box or selecting an option from drop-down box etc.
2. Assertions: They verify that the state of application conforms to what is expected.. Ex: ‘verify that this checkbox is checked’, ‘make sure that the page title is X’.
3. Accessors: Checks the state of application and store the results in a variable.. Ex: storeText, storeTitle, etc.
Question 257. How do you add check points or verification points?
Answer:
They are called as Assertions in selenium. ‘assert’, ‘verify’ and ‘waitFor’ are the commands used to add check points.. Ex: assertText, verifyElementPresent, waitForTextPresent, etc.
Question 258. Name some commands that you use frequently in IDE?
Answer:
Open, click, type, select, assertText, assertTitle, assertTextPresent, verifyText, verifyTextPresent, veriftTitle, waitForText, waitForTextPresent, waitForTitle, store, storeText, storeTitle, check, uncheck, pause, mouseover, etc.
Question 259. What is the difference between assert and verify?
Answer:
When an ‘assert’ fails, the test is aborted where as when ‘verify’ fails, the test will continue execution logging the failure.
‘assert’ is used when the expected value is mandatory to continue with next set of steps. However ‘verify’ is used when the expected value is optional to continue with the next set of steps.
Question 260. Difference between waitFor and pause commands?
Answer:
‘waitFor’ command waits for some condition to become true.
For example, ‘waitForPageToLoad(20000)’– it will wait upto 20 thousand milliseconds to load required page. If the page is loaded before 20,000ms then it jumps to next step to execute.. If the page is not loaded before 20,000ms then it stops the execution due to time-out error.
–> pause command stops the execution of the test until the specified time.
Ex: pause(10000)– It stops the execution of test for 1o thousand milliseconds.. After completing 10,000ms it jumps to next command to execute.. I prefer ‘waitFor’ command than ‘pause’.