Which Selenium class is primarily used to take screenshots in Java?
A) WebDriver
B) TakesScreenshot
C) Actions
D) Alert
Answer: B) TakesScreenshot
Which method captures the screenshot in Selenium WebDriver?
A) getScreenshot()
B) captureScreenshot()
C) getScreenshotAs()
D) takeScreen()
Answer: C) getScreenshotAs()
Which output type is commonly used with getScreenshotAs()?
A) OutputType.STRING
B) OutputType.BYTES
C) OutputType.FILE
D) OutputType.IMAGE
Answer: C) OutputType.FILE
In Selenium, which interface must be implemented to take a screenshot of a web element?
A) WebDriver
B) TakesScreenshot
C) WebElement
D) None of the above
Answer: B) TakesScreenshot
Which Java class is used to save a screenshot file after capturing in Selenium?
A) File
B) BufferedWriter
C) FileReader
D) InputStream
Answer: A) File
Which of the following is correct syntax to take a full-page screenshot in Selenium?
A) driver.getScreenshotAs(OutputType.FILE);
B) driver.captureScreenshot();
C) driver.takeScreen();
D) driver.saveScreenshot();
Answer: A) driver.getScreenshotAs(OutputType.FILE);
Can Selenium take screenshots of the entire desktop or only the browser window?
A) Entire desktop
B) Only the browser window
C) Both
D) Neither
Answer: B) Only the browser window
Which method is used to take a screenshot of a specific WebElement?
A) WebElement.getScreenshotAs(OutputType.FILE);
B) WebElement.takeScreenshot();
C) WebElement.capture();
D) WebElement.saveScreenshot();
Answer: A) WebElement.getScreenshotAs(OutputType.FILE);
Which library helps to copy screenshot files in Selenium Java?
A) java.io.File
B) org.apache.commons.io.FileUtils
C) java.util.Scanner
D) java.awt.Robot
Answer: B) org.apache.commons.io.FileUtils
True or False: Screenshots can be taken only after the page is fully loaded in Selenium.
Answer: True
Which of the following can be used to take screenshots in Python Selenium?
A) driver.save_screenshot(“file.png”)
B) driver.get_screenshot_as_file(“file.png”)
C) Both A & B
D) None
Answer: C) Both A & B
What exception might occur if the element is not visible while taking a screenshot of a WebElement?
A) ElementNotVisibleException
B) NoSuchElementException
C) IOException
D) StaleElementReferenceException
Answer: A) ElementNotVisibleException
Which Selenium method returns a byte array of the screenshot?
A) getScreenshotAs(OutputType.BYTES)
B) getScreenshotAs(OutputType.FILE)
C) getScreenshotAs(OutputType.STRING)
D) takeScreenshot()
Answer: A) getScreenshotAs(OutputType.BYTES)
True or False: Screenshots can be integrated into test reports using frameworks like TestNG or JUnit.
Answer: True
Which Selenium class is used for capturing full-page screenshots in recent versions?
A) ChromeDriver
B) FirefoxDriver
C) TakesScreenshot
D) Augmenter
Answer: D) Augmenter
In Python Selenium, which method captures a screenshot as a PNG in memory?
A) driver.get_screenshot_as_png()
B) driver.capture_png()
C) driver.take_screenshot()
D) driver.screenshot()
Answer: A) driver.get_screenshot_as_png()
Screenshots in Selenium are mostly used for:
A) Debugging
B) Logging failures
C) Documentation
D) All of the above
Answer: D) All of the above
What is the return type of driver.getScreenshotAs(OutputType.FILE) in Java?
A) File
B) String
C) Boolean
D) BufferedImage
Answer: A) File
Which of the following is a good practice when saving screenshots in Selenium tests?
A) Overwrite the same file every time
B) Save with unique timestamp
C) Save in the system root directory
D) Not saving screenshots at all
Answer: B) Save with unique timestamp
Can Selenium take screenshots of alerts or pop-ups directly?
A) Yes, always
B) No, must handle alert first
C) Only in Firefox
D) Only in Chrome