Watir MCQs and Answers With Explanation – Watir, short for Web Application Testing in Ruby, is a popular testing tool for automating web browsers. It provides an easy-to-use and flexible framework for testing web applications and is widely used in the software industry. The Watir MCQs With Answers is designed to test your knowledge of the tool and its features.
Watir MCQs
By answering these Watir Multiple Choice Questions, you can evaluate your understanding of the basics of Watir and identify areas where you may need to improve your knowledge. Whether you are a beginner or an experienced user, this Watir Testing Online Test can help you gauge your proficiency with Watir and improve your testing skills. By scrolling down to the next section you come across the Top 45 Watir MCQ Questions along with a detailed explanation. Make sure you check each and every question and know the correct answer for it to improve your knowledge.
Watir Multiple Choice Questions
Name | Watir |
Exam Type | MCQ (Multiple Choice Questions) |
Category | Technical Quiz |
Mode of Quiz | Online |
Top 50 Watir MCQ Questions | Practice Online Quiz
1. What is Watir?
A) A programming language
B) A web application testing tool
C) An operating system
D) A database management system
Answer: B) A web application testing tool
Explanation: Watir stands for Web Application Testing in Ruby. It is a Ruby library that allows automated testing of web applications through browser automation.
2. Which of the following browsers is not supported by Watir?
A) Google Chrome
B) Mozilla Firefox
C) Internet Explorer
D) Opera
Answer: D) Opera
Explanation: Watir supports Google Chrome, Mozilla Firefox, and Internet Explorer but does not support Opera.
3. Which of the following is not a key feature of Watir?
A) Cross-browser testing
B) Headless testing
C) Image comparison testing
D) Record and playback
Answer: C) Image comparison testing
Explanation: Image comparison testing is not a key feature of Watir. However, Watir supports cross-browser testing, headless testing, and record and playback.
4. What is the main programming language used for writing Watir scripts?
A) Ruby
B) Python
C) Java
D) C++
Answer: A) Ruby
Explanation: Ruby is the main programming language used for writing Watir scripts. Watir is a Ruby library that allows automated testing of web applications.
5. What is the purpose of the ‘require’ statement in Watir?
A) To load a Watir extension
B) To import a Ruby module
C) To open a browser window
D) To define a variable
Answer: B) To import a Ruby module
Explanation: The ‘require’ statement is used to import a Ruby module in Watir. This statement is used to load a required library or extension.
6. Which of the following Watir methods is used to open a browser window?
A) open_browser()
B) launch_browser()
C) start_browser()
D) browser()
Answer: D) browser()
Explanation: The ‘browser()’ method is used to open a browser window in Watir. This method returns a browser object that is used to interact with the web application.
7. Which of the following Watir methods is used to navigate to a specific URL?
A) go_to()
B) navigate_to()
C) visit()
D) access()
Answer: C) visit()
Explanation: The ‘visit()’ method is used to navigate to a specific URL in Watir. This method accepts a URL as a parameter and loads the page in the browser.
8. Which of the following Watir methods is used to retrieve the title of the current web page?
A) page_title()
B) get_title()
C) title()
D) current_title()
Answer: A) page_title()
Explanation: The ‘page_title()’ method is used to retrieve the title of the current web page in Watir. This method returns the title of the web page as a string.
9. Which of the following Watir methods is used to retrieve the URL of the current web page?
A) page_url()
B) get_url()
C) url()
D) current_url()
Answer: D) current_url()
Explanation: The ‘current_url()’ method is used to retrieve the URL of the current web page in Watir. This method returns the URL of the web page as a string.
10. Which of the following Watir methods is used to retrieve the text of an element on the web page?
A) element_text()
B) get_text()
C) text()
D) inner_text()
Answer: C) text()
Explanation: The ‘text()’ method is used to retrieve the text of an element on the web page in Watir. This method returns the text of the element as a string.
11. Which of the following Watir methods is used to click on an element on the web page?
A) element_click()
B) click_element()
C) click()
D) perform_click()
Answer: C) click()
Explanation: The ‘click()’ method is used to click on an element on the web page in Watir. This method simulates a click event on the element.
12. Which of the following Watir methods is used to enter text into a text field on the web page?
A) element_type()
B) set_text()
C) type()
D) send_keys()
Answer: D) send_keys()
Explanation: The ‘send_keys()’ method is used to enter text into a text field on the web page in Watir. This method sends keystrokes to the text field.
13. Which of the following Watir methods is used to select an option from a drop-down list?
A) element_select()
B) select_element()
C) select()
D) choose()
Answer: C) select()
Explanation: The ‘select()’ method is used to select an option from a drop-down list on the web page in Watir. This method selects an option by its text or value.
14. Which of the following Watir methods is used to check a checkbox on the web page?
A) element_check()
B) check_element()
C) check()
D) perform_check()
Answer: C) check()
Explanation: The ‘check()’ method is used to check a checkbox on the web page in Watir. This method simulates a click event on the checkbox.
15. Which of the following Watir methods is used to uncheck a checkbox on the web page?
A) element_uncheck()
B) uncheck_element()
C) uncheck()
D) perform_uncheck()
Answer: C) uncheck()
Explanation: The ‘uncheck()’ method is used to uncheck a checkbox on the web page in Watir. This method simulates a click event on the checkbox.
16. Which of the following Watir methods is used to retrieve the value of an attribute of an element on the web page?
A) element_get_attribute()
B) get_attribute()
C) attribute()
D) get()
Answer: B) get_attribute()
Explanation: The ‘get_attribute()’ method is used to retrieve the value of an attribute of an element on the web page in Watir. This method returns the value of the attribute as a string.
17. Which of the following Watir methods is used to retrieve the HTML of an element on the web page?
A) element_html()
B) get_html()
C) html()
D) inner_html()
Answer: C) html()
Explanation: The ‘html()’ method is used to retrieve the HTML of an element on the web page in Watir. This method returns the HTML of the element as a string.
18. Which of the following Watir methods is used to retrieve the value of a CSS property of an element on the web page?
A) element_get_css_property()
B) get_css_property()
C) css_property()
D) get_property()
Answer: B) get_css_property()
Explanation: The ‘get_css_property()’ method is used to retrieve the value of a CSS property of an element on the web page in Watir. This method returns the value of the CSS property as a string.
19. Which of the following Watir methods is used to take a screenshot of the current web page?
A) take_screenshot()
B) screenshot()
C) capture_screenshot()
D) get_screenshot()
Answer: A) take_screenshot()
Explanation: The ‘take_screenshot()’ method is used to take a screenshot of the current web page in Watir. This method saves the screenshot as an image
20. Which of the following Watir methods is used to scroll to an element on the web page?
A) element_scroll_into_view()
B) scroll_to_element()
C) scroll_into_view()
D) perform_scroll()
Answer: A) element_scroll_into_view()
Explanation: The ‘element_scroll_into_view()’ method is used to scroll to an element on the web page in Watir. This method scrolls the web page so that the element is visible in the viewport.
21. Which of the following Watir methods is used to wait for an element to become present on the web page?
A) wait_for_element_present()
B) present_element()
C) element_present?()
D) when_present()
Answer: D) when_present()
Explanation: The ‘when_present()’ method is used to wait for an element to become present on the web page in Watir. This method takes the element as an argument and waits until the element is present on the web page.
22. Which of the following Watir methods is used to close the browser?
A) close()
B) quit()
C) exit()
D) end()
Answer: B) quit()
Explanation: The ‘quit()’ method is used to close the browser in Watir. This method closes all browser windows opened by the Watir instance.
23. Which of the following Watir methods is used to upload a file to a web page?
A) upload_file()
B) file_upload()
C) choose_file()
D) upload()
Answer: A) upload_file()
Explanation: The ‘upload_file()’ method is used to upload a file to a web page in Watir. This method takes the file path as an argument and uploads the file to the web page.
24. Which of the following Watir methods is used to wait for an element to appear on the web page?
A) wait_for_element()
B) element_wait()
C) wait_until_element_present()
D) wait_element()
Answer: C) wait_until_element_present()
Explanation: The ‘wait_until_element_present()’ method is used to wait for an element to appear on the web page in Watir. This method waits until the element is present on the web page or until the timeout is reached.
25. Which of the following Watir methods is used to wait for an element to disappear from the web page?
A) wait_for_element_absent()
B) element_absent_wait()
C) wait_until_element_absent()
D) wait_element_absent()
Answer: C) wait_until_element_absent()
Explanation: The ‘wait_until_element_absent()’ method is used to wait for an element to disappear from the web page in Watir. This method waits until the element is not present on the web page or until the timeout is reached.
26. Which of the following Watir methods is used to wait for a web page to load?
A) wait_for_page()
B) page_wait()
C) wait_until_page_loaded()
D) wait_page()
Answer: C) wait_until_page_loaded()
Explanation: The ‘wait_until_page_loaded()’ method is used to wait for a web page to load in Watir. This method waits until the page is loaded or until the timeout is reached.
27. Which of the following Watir methods is used to simulate pressing the enter key?
A) element_send_enter()
B) send_enter()
C) send_keys(:enter)
D) perform_enter()
Answer: C) send_keys(:enter)
Explanation: The ‘send_keys(:enter)’ method is used to simulate pressing the enter key in Watir. This method sends the enter key to the currently focused element.
28. Which of the following Watir methods is used to simulate pressing the tab key?
A) element_send_tab()
B) send_tab()
C) send_keys(:tab)
D) perform_tab()
Answer: C) send_keys(:tab)
Explanation: The ‘send_keys(:tab)’ method is used to simulate pressing the tab key in Watir. This method sends the tab key to the currently focused element.
29. Which of the following Watir methods is used to simulate pressing the escape key?
A) element_send_escape()
B) send_escape()
C) send_keys(:escape)
D) perform_escape()
Answer: C) send_keys(:escape)
Explanation: The ‘send_keys(:escape)’ method is used to simulate pressing the escape key in Watir. This method sends the escape key to the currently focused element.
30. Which of the following Watir methods is used to simulate pressing the space key?
A) element_send_space()
B) send_space()
C) send_keys(:space)
D) perform_space()
Answer: C) send_keys(:space)
Explanation: The ‘send_keys(:space)’ method is used to simulate pressing the space key in Watir. This method sends the space key to the currently focused element.
31. Which of the following Watir methods is used to get the text of an element on the web page?
A) element_text()
B) get_text()
C) text()
D) inner_text()
Answer: A) element_text()
Explanation: The ‘element_text()’ method is used to get the text of an element on the web page in Watir. This method returns the text of the element as a string.
32. Which of the following Watir methods is used to get the value of an attribute of an element on the web page?
A) element_value()
B) get_value()
C) attribute_value()
D) attribute()
Answer: C) attribute_value()
Explanation: The ‘attribute_value()’ method is used to get the value of an attribute of an element on the web page in Watir. This method takes the name of the attribute as an argument and returns the value of the attribute as a string.
33. Which of the following Watir methods is used to get the HTML code of an element on the web page?
A) element_html()
B) get_html()
C) html()
D) inner_html()
Answer: A) element_html()
Explanation: The ‘element_html()’ method is used to get the HTML code of an element on the web page in Watir. This method returns the HTML code of the element as a string.
34. Which of the following Watir methods is used to get the value of a CSS property of an element on the web page?
A) element_css_value()
B) get_css_value()
C) css_value()
D) style_value()
Answer: A) element_css_value()
Explanation: The ‘element_css_value()’ method is used to get the value of a CSS property of an element on the web page in Watir. This method takes the name of the CSS property as an argument and returns the value of the CSS property as a string.
35. Which of the following Watir methods is used to select an option from a select list on the web page?
A) element_select()
B) select()
C) select_option()
D) choose_option()
Answer: A) element_select()
Explanation: The ‘element_select()’ method is used to select an option from a select list on the web page in Watir. This method takes the value or text of the option as an argument and selects the option.
36. Which of the following Watir methods is used to click on a link on the web page?
A) element_click()
B) click()
C) click_link()
D) choose_link()
Answer: C) click_link()
Explanation: The ‘click_link()’ method is used to click on a link on the web page in Watir. This method clicks on the link with the specified text or id.
37. Which of the following Watir methods is used to click on a button on the web page?
A) element_click()
B) click()
C) click_button()
D) choose_button()
Answer: C) click_button()
Explanation: The ‘click_button()’ method is used to click on a button on the web page in Watir. This method clicks on the button with the specified text, id or value.
38. Which of the following Watir methods is used to submit a form on the web page?
A) element_submit()
B) submit()
C) submit_form()
D) submit_button()
Answer: A) element_submit()
Explanation: The ‘element_submit()’ method is used to submit a form on the web page in Watir. This method submits the form containing the element.
39. Which of the following Watir methods is used to fill in a text field on the web page?
A) element_fill()
B) fill_in()
C) enter_text()
D) type_text()
Answer: B) fill_in()
Explanation: The ‘fill_in()’ method is used to fill in a text field on the web page in Watir. This method takes the name or id of the text field and the value to be filled in as arguments.
40. Which of the following Watir methods is used to set the value of a text field on the web page?
A) element_set()
B) set_text()
C) set_value()
D) set_field()
Answer: C) set_value()
Explanation: The ‘set_value()’ method is used to set the value of a text field on the web page in Watir. This method takes the value to be set as an argument and sets the value of the text field.
41. Which of the following Watir methods is used to clear the text of a text field on the web page?
A) element_clear()
B) clear()
C) clear_field()
D) erase()
Answer: A) element_clear()
Explanation: The ‘element_clear()’ method is used to clear the text of a text field on the web page in Watir. This method clears the text of the element.
42. Which of the following Watir methods is used to check if an element is present on the web page?
A) element_present?
B) present?
C) exists?
D) is_present?
Answer: C) exists?
Explanation: The ‘exists?’ method is used to check if an element is present on the web page in Watir. This method returns ‘true’ if the element exists and ‘false’ otherwise.
43. Which of the following Watir methods is used to check if an element is visible on the web page?
A) element_visible?
B) visible?
C) is_visible?
D) viewable?
Answer: C) is_visible?
Explanation: The ‘is_visible?’ method is used to check if an element is visible on the web page in Watir. This method returns ‘true’ if the element is visible and ‘false’ otherwise.
44. Which of the following Watir methods is used to take a screenshot of the web page?
A) screenshot()
B) take_screenshot()
C) capture_screen()
D) screen_capture()
Answer: B) take_screenshot()
Explanation: The ‘take_screenshot()’ method is used to take a screenshot of the web page in Watir. This method takes the path to save the screenshot as an argument and saves
45. Which of the following Watir methods is used to scroll to a specific element on the web page?
A) scroll_to()
B) element_scroll()
C) scroll_element()
D) scrollToElement()
Answer: A) scroll_to()
Explanation: The ‘scroll_to()’ method is used to scroll to a specific element on the web page in Watir. This method takes the element as an argument and scrolls the page until the element is in view.
Have you got sufficient information about the Watir and where and why it is used from the above provided Watir Multiple Choice Questions? Then we urge the aspirants to keep following our Freshersnow website to be able to get such useful articles daily.