Selenium Interview QA

1. What is selenium webdriver?

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.

2. How to write the tests in selenium WebDriver?

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.
3. How to configure selenium webdriver in eclipse?

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.
4. What are the prerequisites to run selenium webdriver?

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.
5. What is the difference between selenium 1.0 and webdriver?

Selenium 1.0 needs Selenium RC to run a test. However, webdriver can directly launch a browser and run tests.
6. What are the advantages of selenium webdriver?

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.

7. What are the disadvantages of selenium webdriver over selenium 1.0?

Since selenium web driver requires coding skills, QA engineers should have some knowledge of program development in Java, .Net, or other languages.

8. How to handle multiple windows in selenium webdriver?

We can use web driver’s windows handler to identify each window and use switch method to pick the window for test.

9. How to navigate with browser buttons in selenium webdriver?

We can use web driver’s back or forward method to simulate browser’s navigation button functionality.

10. Which are the locators used for recognizing the objects in selenium webdriver?

In webdriver, we can use element id, name, css, xpath, link text, partial link text and DOM to locate elements.

11. How to run the tests in internet explorer using selenium webdriver?

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.
12. How to run the tests in firefox using selenium webdriver?

In the setup method, we select FirefoxDriver for the webDriver.
13. How to run the tests in google chrome using selenium webdriver?

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.

14. How to run the tests without a browser or with HTML unit driver in selenium webdriver?

WebDriver driver = new HtmlUnitDriver();

15. How to run Selenium 1.0 tests in webdriver?

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”);

16. How to convert selenium 1.0 tests to webdriver tests?

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”);

17. What is webdriver backed selenium?

WebDriver backed Selenium is API that enables running Selenium 1.0 tests in web driver.

18. When to use web driver backed selenium?

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.

19. Which version of selenium IDE supports webdriver?

Any version higher than 2.0 supports webdriver.

20. How to invoke an application in webdriver?

We can use Process to invoke application in the code using web driver.

21. Which of Selenium IDE commands not supported in webdriver?

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.

22. Where to download selenium webdriver?

Selenium WebDriver libraries can be download from http://www.seleniumhq.org website.

23. What is implicit and explicit wait in selenium webdriver?

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.
24. What is the difference between an assert and a verify with Selenium commands?
25. What Selenese commands can be used to help debug a regexp?

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.
26. What is one big difference between SilkTest and Selenium, excluding the price?

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.

27. Which browsers can Selenium IDE be run in?

Selenium IDE is firefox ad on, so it runs on Firefox browser.

28. If a Selenium function requires a script argument, what would that argument look like in general terms?

That should be java script argument.

29. If a Selenium function requires a pattern argument, what five prefixes might that argument have?

* 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
30. What is the regular expression sequence that loosely translates to “anything or nothing?”

* which translates to “match anything,” i.e., nothing, a single character, or many characters.
31. What is the globbing sequence that loosely translates to “anything or nothing?

glob: label

32. What does a character class for all alphabetic characters and digits look like in regular expressions?

[a-zA-Z0-9] matches any alphanumeric character
33. What does a character class for all alphabetic characters and digits look like in globbing?

regexp: *[a-zA-Z0-9]

34. What must one set within SIDE in order to run a test from the beginning to a certain point within the test?

We need to set a break point in the test, so the test will pause at the break point.

35. What does a right-pointing green triangle at the beginning of a command in SIDE indicate?

That triangle indicates that test paused at that step, or will start from that step.

36. How does one get rid of the right-pointing green triangle?

Right click on that line and remove break point.

37. How can one add vertical white space between sections of a single test?

User can input comment line between test steps, and in the comment line, add spaces.

38. What Selenium functionality uses wildcards?

Regular expression can use wildcards.

39. Which wildcards does SIDE support?

*, ?, :
40. What are the main types of regular expression quantifiers you know?

* 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
41. What regular expression special character(s) means “any character?”

* symbol means any character

42. What distinguishes between an absolute and relative URL in SIDE?

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.

43. How would one access a Selenium variable named “count” from within a JavaScript snippet?

${count}

44. What Selenese command can be used to display the value of a variable in the log file, which can be very valuable for debugging?

We can use echo command to log information in the test result output.

45. 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?

echo ${variableName}

46. Where did the name “Selenium” come from?

Actually, Selenium is a chemical element name. But Thoughtworks used it for test automation framework api.

47. Which Selenium command(s) simulates selecting a link?

Selenium has several commands to verify links. For simulating selecting a link, we can use findElement(By.Link(“LinkName”))

48. Which two commands can be used to check that an alert with a particular message popped up?

Use command VerifyAlertPresent

49. What does a comment look like in Column view?

Comments display in pink color

50. What does a comment look like in Source view?

<!–This is second comment–>
<!–This is a comment–>

51. What are Selenium tests normally named (as displayed at the top of each test when viewed from within a browser)?

In the browser, the test name in Selenium IDE will be displayed.

52. What command simulates selecting the browser’s Back button?

goBack command

53. If the Test Case frame contains several test cases, how can one execute just the selected one of those test cases?

Users can use “Play current test case” function of Selenium IDE

54. What globbing functionality is NOT supported by SIDE?

Globbing supports * or ?, so other patterns are not supported by globbing. We need to use Regular Expressions for that.

55. What is wrong with this character class range? [A-z]

It should be [a-z]; A should be written as lower case.

56. What are three ways of specifying an uppercase or lowercase M in a Selenese pattern?

We can use globbing, regular expression, and exact.
Uppercase: [A-Z]
Lowercase: [a-z]

57. What does this regular expression match?
regexp:[1-9][0-9],[0-9]{3},[0-9]{4}

If we use the number 1
match: 11,111,1111

58. What are two ways to match an asterisk within a Selenese regexp?

* or any symbol with *

59. What is the generic name for an argument (to a Selenese command) which starts with //?

Xpath

60. What Selenese command is used to choose an item from a list?

Select command

61. How many matches exist for this pattern?

regexp:[13579][02468]

25 (basically, any odd number from this group [13579] and any even number from this [02468])

62. What is the command associated with testing an alert?

AssertAlert,AssertAlertNoPresent

63. How can one get SIDE to always record an absolute URL for the open command’s argument?

In the Selenium IDE options, check “Record Absolute URL” option.

64. What Selenese command and argument can be used to transfer the value of a JavaScript variable into a SIDE variable?

Use “store” command

65. 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?

${variableName}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s