Selenium(Computer Science ) Questions and Answers

Question 1. Which is the incorrect statement for X-path?
  1.    Xpath can work with text, CSS cannot work
  2.    Xpath has more combination and can search by index CSS cannot search by index, but css is working faster than Xpath
  3.    with Xpath, we can search elements backward or forward... while css works only in forward direction •
  4.    with Xpath we cannot work with text, CSS we can
Explanation:-
Answer: Option D. -> with Xpath we cannot work with text, CSS we can

Question 2. How do you maximize a web page?
  1.    driver.manage().window().maximize();
  2.    driver.manage().window().enlarge();
  3.    driver.manage().maximize();
  4.    driver.manage().enlarge
Explanation:-
Answer: Option A. -> driver.manage().window().maximize();

Question 3. Which method to use to get an element from webpage?
  1.    findElements()
  2.    searchElement()
  3.    getElement()
  4.    findElement()
Explanation:-
Answer: Option D. -> findElement()

Question 4. Which is the correct syntax of DOM?
  1.    Text
  2.    Text
  3.    $tag attr1=value1, attr2=value2$Text$/tag$
  4.    Text
Explanation:-
Answer: Option D. -> Text

Question 5. Which one is NOT one of the Selenium's suites?
  1.    Selenium IDE
  2.    Selenium RC
  3.    Selenium Grid
  4.    Selenium WebDriverManager
Explanation:-
Answer: Option D. -> Selenium WebDriverManager

Question 6. Which is the correct syntax to find all links in the page?
  1.    List list = driver.findElements(By.tagName('a'));
  2.    WebElement list = driver.findElements(By.tagName(“a”));
Explanation:-
Answer: Option A. -> List list = driver.findElements(By.tagName('a'));

Question 7. Difference between quit() and close()?
  1.    quit() method quits the active window only, close() method closes the active window
  2.    quit() method quits the active window only, close() method closes all opened windows.
  3.    quit() method quits all opened windows, close() method closes the active window only.
  4.    quit() method closes all opened windows, close() method opens a browser session
Explanation:-
Answer: Option C. -> quit() method quits all opened windows, close() method closes the active window only.

Question 8. Which method to use to close a webpage?Hint :
  1.    quit()
  2.    close()
  3.    disconnect()
  4.    Both A & B
Explanation:-
Answer: Option D. -> Both A & B

Question 9. Which of the following is a syntax for an x path to find an element?
  1.    tagname[@attribute=`value`]
  2.    atribute[@tagname=`value`]
  3.    input[tagname='value']
  4.    a[value='attribute']
Explanation:-
Answer: Option A. -> tagname[@attribute=`value`]

Question 10. In test automation, framework is the blueprint of test automation
  1.    True
  2.    False
Explanation:-
Answer: Option A. -> True