

















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















































































Question 1. Which command retrieves the visible text of an element in WebdriverIO? A) getText() B) getAttribute() C) getValue() D) getHTML() Answer: A Explanation: getText() returns the rendered text that a user can see inside the element. Question 2. In a wdio.conf.js file, which property defines the test files to be executed? A) capabilities B) specs C) reporters D) services Answer: B Explanation: The specs array lists the glob patterns that locate test specification files. Question 3. Which npm package provides the command line interface for initializing a WebdriverIO project? A) @wdio/cli B) webdriverio-core C) @wdio/runner D) wdio-service Answer: A Explanation: @wdio/cli contains the wdio executable used to run the configuration wizard and start tests.
Question 4. What is the default protocol used by WebdriverIO when running in standard mode? A) WebDriver BiDi B) Selenium Grid C) WebDriver (JSON Wire) D) CDP (Chrome DevTools Protocol) Answer: C Explanation: By default, WebdriverIO communicates with browsers via the WebDriver protocol (JSON Wire or W3C). Question 5. Which selector strategy is most performant for locating a single element? A) XPath B) CSS selector C) Link text D) Accessibility selector Answer: B Explanation: CSS selectors are parsed natively by browsers and are typically faster than XPath or other strategies. Question 6. How can you interact with an element inside a Shadow DOM using WebdriverIO? A) Use shadow$() method B) Use $(‘#shadow-root’) C) Use browser.execute() with shadowRoot property D) Use browser.shadow$()
D) beforeSession() Answer: D Explanation: beforeSession is executed once before the WebDriver session is created and before any suites run. Question 10. Which assertion verifies that an element’s attribute equals a specific value? A) toHaveText() B) toHaveAttribute() C) toBeDisplayed() D) toHaveUrl() Answer: B Explanation: toHaveAttribute() checks that the element’s attribute matches the expected string. Question 11. What is the purpose of the browser.execute() command? A) To run a WebDriver command directly B) To execute arbitrary JavaScript in the browser context C) To switch to a different window D) To capture a screenshot Answer: B Explanation: browser.execute() runs a JavaScript function inside the page, allowing complex interactions not covered by built‑in commands. Question 12. Which capability key is used to run tests on multiple browsers simultaneously (multi‑remote)? A) maxInstances
B) browserName C) shardTestFiles D) capabilities (array of objects) Answer: D Explanation: Providing an array of capability objects under capabilities enables multi‑remote execution where each object defines a distinct browser session. Question 13. Which WebdriverIO command retrieves the value of a selected option in a <select> element? A) getValue() B) getSelected() C) getAttribute('value') D) getText() Answer: A Explanation: getValue() returns the value attribute of the currently selected option in a <select> element. Question 14. How do you pause test execution and open an interactive REPL session? A) browser.pause() B) browser.debug() C) browser.waitUntil() D) browser.step() Answer: B Explanation: browser.debug() halts execution and opens a Node REPL connected to the running session.
Explanation: browser.switchToFrame() changes the execution context to the specified iframe element. Question 18. What does the connectionRetryTimeout setting define? A) Time to wait for a command response before retrying B) Maximum time to establish a new WebDriver session C) Interval between retry attempts for failed commands D) Timeout for page load events Answer: B Explanation: connectionRetryTimeout specifies how long WebdriverIO will try to establish a session before giving up. Question 19. Which command accepts a JavaScript function that returns a boolean to create a custom wait condition? A) waitForDisplayed() B) waitUntil() C) waitForExist() D) waitForEnabled() Answer: B Explanation: browser.waitUntil(fn, { timeout, timeoutMsg }) repeatedly calls the provided function until it returns true. Question 20. How can you set an environment variable for a specific test run without modifying the config file? A) Use wdio --env QA B) Export the variable before running wdio (e.g., NODE_ENV=staging wdio)
C) Define it in wdio.conf.js under env D) Pass it as a capability Answer: B Explanation: Prefixing the command with VARIABLE=value sets the environment variable for that process. Question 21. Which command retrieves the current page URL? A) getUrl() B) getCurrentUrl() C) getLocation() D) getHref() Answer: A Explanation: browser.getUrl() returns the URL of the active browser tab. Question 22. Which selector strategy is specifically designed for accessibility testing? A) css selector B) xpath C) aria selector (~) D) link text Answer: C Explanation: WebdriverIO supports accessibility selectors using the ~ prefix to match aria- label, aria-labelledby, etc. Question 23. What does the maxInstances option control in a WebdriverIO config? A) Number of browsers that can run in parallel on a single machine
A) acceptAlert() B) alertAccept() C) acceptPrompt() D) dismissAlert() Answer: A Explanation: browser.acceptAlert() clicks the OK button on the active alert dialog. Question 27. In mobile testing with Appium, which capability specifies the platform version? A) platformVersion B) deviceVersion C) osVersion D) mobileVersion Answer: A Explanation: platformVersion tells Appium which OS version (iOS or Android) to target. Question 28. Which command scrolls an element into view? A) scrollIntoView() B) moveTo() C) scrollTo() D) bringIntoView() Answer: A Explanation: element.scrollIntoView() uses the browser’s native method to bring the element into the viewport.
Question 29. What is the purpose of the baseUrl property in wdio.conf.js? A) To set the default domain for relative URL navigation B) To define the WebDriver server address C) To configure the base path for screenshots D) To set the base directory for test files Answer: A Explanation: baseUrl is prepended to relative URLs passed to browser.url(). Question 30. Which command retrieves the HTML source of the current page? A) getPageSource() B) getSource() C) getHTML() D) getContent() Answer: A Explanation: browser.getPageSource() returns the complete HTML markup of the page. Question 31. How can you run tests in parallel across multiple spec files? A) Set maxInstances and specs in config, then use wdio run B) Use wdio run --parallel flag C) Define parallel: true in wdio.conf.js D) It is not supported in WebdriverIO Answer: A Explanation: WebdriverIO distributes spec files across available instances based on maxInstances.
A) External utilities that run alongside the test runner (e.g., ChromeDriver) B) Assertion libraries C) Reporting tools only D) Browser capabilities Answer: A Explanation: Services like chromedriver, selenium-standalone, or docker are started automatically when listed. Question 36. Which command retrieves the value of a CSS property from an element? A) getCssValue() B) getStyle() C) getComputedStyle() D) getProperty() Answer: A Explanation: element.getCSSProperty('color') returns the computed CSS value. Question 37. How can you execute a test only on a specific browser (e.g., Chrome) using capabilities? A) Add if (browser.capabilities.browserName === 'chrome') inside the test B) Use exclude property in config C) Define a separate config file with Chrome capabilities and run that file D) Set browserOnly: true in capabilities Answer: C Explanation: Creating a config that only contains Chrome capabilities and invoking it ensures the test runs solely on Chrome.
Question 38. Which command switches the context back to the main document from an iframe? A) switchToParentFrame() B) switchToFrame(null) C) switchToParentWindow() D) switchToMain() Answer: A Explanation: browser.switchToParentFrame() exits the current iframe and returns to the top‑level document. Question 39. In WebdriverIO, what does the $ function return? A) A single element object (WebdriverIO Element) B) An array of elements C) A promise that resolves to an element D) A string selector Answer: A Explanation: $ resolves to a single Element instance representing the first matching node. Question 40. Which command is used to close the current browser window? A) closeWindow() B) close() C) browser.closeWindow() D) browser.close() Answer: C Explanation: browser.closeWindow() closes the active window or tab.
Explanation: $$('selector').map(el => el.getText()) works, but WebdriverIO provides a shortcut $$('selector').getText() which returns an array of texts. Question 44. Which hook runs after each individual test step in Cucumber? A) afterStep() B) afterScenario() C) afterTest() D) afterHook() Answer: A Explanation: afterStep is triggered after every step when using the Cucumber framework. Question 45. What is the purpose of the shardTestFiles option? A) To split test files across multiple instances for parallel execution B) To divide a single test file into multiple parts C) To enable test retry on failure D) To group tests by tags Answer: A Explanation: shardTestFiles: true tells WebdriverIO to distribute spec files among available workers. Question 46. Which command simulates a swipe gesture on a mobile device? A) touchAction('swipe') B) driver.swipe() C) browser.touchAction([{ action: 'press', x, y }, { action: 'moveTo', x, y }, { action: 'release' }]) D) browser.swipe()
Answer: C Explanation: browser.touchAction() with a sequence of press, moveTo, and release replicates a swipe. Question 47. Which reporter outputs a simple dot for each test? A) spec B) dot C) allure D) junit Answer: B Explanation: The dot reporter prints a single dot per test, providing a compact view. Question 48. How can you add a custom command called login to the browser object? A) browser.addCommand('login', function(){ ... }) B) browser.command('login', () => { ... }) C) browser.registerCommand('login', function(){ ... }) D) browser.extend('login', function(){ ... }) Answer: A Explanation: browser.addCommand('login', fn) registers a new method on the browser instance. Question 49. Which method retrieves the list of all cookies currently stored? A) getAllCookies() B) getCookies() C) getAll()
C) Automatic screenshot capture D) Auto‑retry of failed tests Answer: A Explanation: autoCompileOpts lets WebdriverIO compile TS/ES6 files on the fly using the specified compiler. Question 53. Which command retrieves the innerHTML of an element? A) getHTML() B) getAttribute('innerHTML') C) getProperty('innerHTML') D) getHTML(false) Answer: C Explanation: element.getProperty('innerHTML') returns the raw HTML inside the element. Question 54. How can you run a single test file without executing the entire suite? A) Use wdio run wdio.conf.js --spec path/to/file.spec.js B) Comment out all other specs in the config C) Set only: true on the test D) Use wdio run --single path/to/file Answer: A Explanation: The --spec CLI option limits execution to the provided spec pattern. Question 55. Which command scrolls the page to the bottom? A) browser.scrollTo(0, document.body.scrollHeight) via execute B) browser.scrollToEnd()
C) browser.scrollToBottom() D) browser.scroll(0, 9999) Answer: A Explanation: Using browser.execute(() => window.scrollTo(0, document.body.scrollHeight)) scrolls to the page’s end. Question 56. Which assertion verifies that the current URL contains a specific substring? A) toContainUrl() B) toMatchUrl() C) toHaveUrlContaining() D) toIncludeUrl() Answer: C Explanation: expect(browser).toHaveUrlContaining('dashboard') checks that the URL includes the given text. Question 57. In WebdriverIO, what does the waitforEnabled command do? A) Waits until the element is enabled (not disabled) B) Waits until the element is visible C) Waits for the element to be present in DOM D) Waits for the element to be clickable Answer: A Explanation: element.waitForEnabled() pauses execution until the element’s disabled attribute is removed. Question 58. Which capability is required to run tests on Safari on macOS? A) browserName: 'safari'