Sunday, August 25, 2024

Handling Auto-Suggestion Using Selenium Java MCQ

 MCQs on Handling Auto-Suggestion Using Selenium Java

Which Selenium WebDriver method is commonly used to send text to a search box to trigger auto-suggestions?


a) sendText("text")

b) sendKeys("text")

c) setInput("text")

d) type("text")

Answer: b) sendKeys("text")


To capture all auto-suggestions displayed in a drop-down, which Selenium method is most appropriate?


a) findElement(By.name("suggestions"))

b) findElement(By.className("suggestions"))

c) findElements(By.xpath("//ul[@role='listbox']//li"))

d) findElement(By.cssSelector("div.suggestions"))

Answer: c) findElements(By.xpath("//ul[@role='listbox']//li"))


How do you select an auto-suggestion from the list that matches a specific text using Selenium?


a) Use element.selectByText("suggestion")

b) Use a loop with getText() and click()

c) Use driver.selectOptionByText("suggestion")

d) Use driver.pick("suggestion")

Answer: b) Use a loop with getText() and click()


Which method is used to simulate typing in a text box to trigger auto-suggestions?


a) element.inputText("query")

b) element.type("query")

c) element.sendKeys("query")

d) element.enterText("query")

Answer: c) element.sendKeys("query")


What is the purpose of using Thread.sleep() when handling auto-suggestions in Selenium?


a) To stop the browser

b) To wait for the suggestions to appear

c) To close the auto-suggestion list

d) To refresh the page

Answer: b) To wait for the suggestions to appear


In a scenario where you need to handle dynamic auto-suggestions, what is the best practice?


a) Use hard-coded wait times

b) Use WebDriverWait with ExpectedConditions

c) Refresh the page frequently

d) Use static waits

Answer: b) Use WebDriverWait with ExpectedConditions


When handling auto-suggestions, what Selenium method is best for scrolling to a specific suggestion in the list?


a) scrollToElement()

b) Actions.moveToElement(element).build().perform()

c) scrollIntoView()

d) scrollDownTo()

Answer: b) Actions.moveToElement(element).build().perform()


To avoid StaleElementReferenceException while handling auto-suggestions, what approach should be followed?


a) Refresh the page and retry

b) Store the elements in a list and use them directly

c) Always re-fetch elements after triggering the suggestion

d) Increase the timeout

Answer: c) Always re-fetch elements after triggering the suggestion


How can you verify the total number of auto-suggestions displayed after entering text in a search box?


a) element.countSuggestions()

b) driver.findElements(By.xpath("//ul[@role='listbox']//li")).size()

c) driver.getSuggestionsCount()

d) driver.findElements(By.className("suggestion")).size()

Answer: b) driver.findElements(By.xpath("//ul[@role='listbox']//li")).size()


Which ExpectedConditions is used to ensure that auto-suggestions are visible before interacting with them?


a) visibilityOfElementLocated(By.xpath(...))

b) presenceOfElementLocated(By.xpath(...))

c) elementToBeClickable(By.xpath(...))

d) textToBePresentInElement(By.xpath(...))

Answer: a) visibilityOfElementLocated(By.xpath(...))


What is the Selenium strategy to interact with a dynamic list of auto-suggestions?


a) Use index-based clicks

b) Use the text-based search and click method

c) Use selectByVisibleText()

d) Use JavaScript to select the element

Answer: b) Use the text-based search and click method


Which approach is most reliable for dealing with rapidly changing auto-suggestions?


a) Use Thread.sleep() generously

b) Use FluentWait to handle dynamic waits

c) Use only CSS selectors

d) Increase the timeout to a very high value

Answer: b) Use FluentWait to handle dynamic waits


Which Selenium class is most useful for automating actions such as typing and selecting auto-suggestions?


a) Actions

b) JavascriptExecutor

c) Select

d) WebDriver

Answer: a) Actions


If the auto-suggestion list is not clickable, what is a good workaround in Selenium?


a) Use JavaScript to perform a click

b) Use sendKeys(Keys.ENTER) to select the first suggestion

c) Refresh the page and retry

d) Use driver.clickOnInvisibleElement()

Answer: a) Use JavaScript to perform a click


When selecting a specific auto-suggestion based on visible text, which Selenium WebDriver approach is most effective?


a) Iterate through the list and match text with getText()

b) Use driver.findElement(By.visibleText())

c) Use driver.clickElementByText()

d) Use selectOption("text")

Answer: a) Iterate through the list and match text with getText()


Which command is used to press the down arrow key to navigate through auto-suggestions?


a) element.sendKeys(Keys.DOWN)

b) element.press(Keys.ARROW_DOWN)

c) element.arrowDown()

d) element.sendKey(Keys.ARROW_DOWN)

Answer: a) element.sendKeys(Keys.DOWN)


What is the advantage of using FluentWait over WebDriverWait when handling dynamic auto-suggestions?


a) FluentWait allows for more frequent polling intervals and custom exception handling

b) FluentWait has a longer default timeout

c) FluentWait can refresh the page automatically

d) FluentWait ignores all exceptions

Answer: a) FluentWait allows for more frequent polling intervals and custom exception handling


In Selenium, how would you dynamically select an auto-suggestion using partial text matching?


a) driver.findElement(By.partialLinkText("suggestion"))

b) Loop through elements and use getText().contains("text")

c) driver.findElement(By.textContains("text"))

d) driver.partialText("text")

Answer: b) Loop through elements and use getText().contains("text")


When auto-suggestions are loaded dynamically via AJAX, what must you ensure before attempting to interact with them?


a) All suggestions have fully loaded and are visible

b) The page is refreshed

c) The input field is cleared

d) A screenshot is taken

Answer: a) All suggestions have fully loaded and are visible

Handling Multiple Browser Windows Using Selenium Java MCQ

 MCQs on Handling Multiple Browser Windows Using Selenium Java

Which method is used to get the unique identifier of the current browser window in Selenium WebDriver?


a) driver.getWindowID()

b) driver.getWindowName()

c) driver.getWindowHandle()

d) driver.getWindowIdentifier()

Answer: c) driver.getWindowHandle()


What does the getWindowHandles() method return in Selenium WebDriver?


a) A string array of window names

b) A set of window handles

c) A list of window objects

d) An integer representing the number of windows

Answer: b) A set of window handles


To switch to a different window in Selenium, which method is used?


a) driver.switchTo().window()

b) driver.navigate().window()

c) driver.switchToWindow()

d) driver.switchWindow()

Answer: a) driver.switchTo().window()


Which of the following methods would you use to close all browser windows opened by the WebDriver?


a) driver.closeAllWindows()

b) driver.quit()

c) driver.close()

d) driver.shutdown()

Answer: b) driver.quit()


If you want to close the current browser window and keep other windows open, which method should you use?


a) driver.quit()

b) driver.close()

c) driver.closeCurrentWindow()

d) driver.closeWindow()

Answer: b) driver.close()


What is the purpose of the getWindowHandles() method in Selenium?


a) To get the title of all open windows

b) To get the handles of all open browser windows

c) To get the URLs of all open browser windows

d) To get the size of all open browser windows

Answer: b) To get the handles of all open browser windows


How do you switch back to the original window after switching to a new window in Selenium WebDriver?


a) Use driver.switchTo().defaultWindow()

b) Use the original window handle with driver.switchTo().window(originalWindowHandle)

c) Use driver.switchTo().previousWindow()

d) Use driver.switchTo().parentWindow()

Answer: b) Use the original window handle with driver.switchTo().window(originalWindowHandle)


Which of the following is true about the getWindowHandle() method in Selenium WebDriver?


a) It returns a list of window handles

b) It returns the handle of the current window as a string

c) It closes the current window

d) It switches to a different window

Answer: b) It returns the handle of the current window as a string


What will happen if you attempt to switch to a window that does not exist using driver.switchTo().window("invalidHandle")?


a) NoSuchWindowException will be thrown

b) NoSuchElementException will be thrown

c) NullPointerException will be thrown

d) The script will continue without any exception

Answer: a) NoSuchWindowException will be thrown


To handle multiple windows, which Java collection is commonly used to store window handles?


a) ArrayList<String>

b) HashSet<String>

c) LinkedList<String>

d) TreeSet<String>

Answer: b) HashSet<String>



When handling multiple windows, why is it essential to use getWindowHandles() instead of getWindowHandle()?


a) getWindowHandles() retrieves handles for all windows, while getWindowHandle() retrieves only the current window handle

b) getWindowHandles() closes all windows, while getWindowHandle() switches to a window

c) getWindowHandles() opens new windows, while getWindowHandle() deletes a window

d) getWindowHandles() retrieves window titles, while getWindowHandle() retrieves window URLs

Answer: a) getWindowHandles() retrieves handles for all windows, while getWindowHandle() retrieves only the current window handle


What is the best practice when switching between multiple browser windows?


a) Use hard-coded window handles

b) Store window handles in a set and iterate through them as needed

c) Switch randomly between windows

d) Refresh all windows before switching

Answer: b) Store window handles in a set and iterate through them as needed


If you need to handle a popup window in Selenium WebDriver, what should you do first?


a) Close the main window

b) Switch to the popup window using its window handle

c) Refresh the browser

d) Use driver.navigate().refresh()

Answer: b) Switch to the popup window using its window handle


How do you handle multiple windows if they have the same title?


a) Use the URL of the windows to differentiate them

b) Use the window index to switch between them

c) Use the window handle, which is always unique

d) Use driver.getWindowByTitle("title")

Answer: c) Use the window handle, which is always unique


What Selenium WebDriver method is used to maximize all open browser windows?


a) driver.manage().window().maximizeAll()

b) driver.switchTo().window().maximize()

c) Selenium WebDriver does not support maximizing all windows at once

d) driver.maximizeWindows()

Answer: c) Selenium WebDriver does not support maximizing all windows at once


In Selenium, how do you check if a particular window handle exists in the set of current window handles?


a) driver.getWindowHandles().contains("windowHandle")

b) driver.windowExists("windowHandle")

c) driver.switchTo().windowExists("windowHandle")

d) driver.hasWindow("windowHandle")

Answer: a) driver.getWindowHandles().contains("windowHandle")


What is a common use case for handling multiple browser windows in Selenium WebDriver?


a) Handling file downloads

b) Automating login processes

c) Switching between main application window and popup or child windows

d) Filling out forms in a single window

Answer: c) Switching between main application window and popup or child windows


How can you verify that you have successfully switched to a new window in Selenium WebDriver?


a) By checking the page title or URL of the new window

b) By checking the source code of the new window

c) By waiting for the window to close automatically

d) By using driver.windowIsOpen()

Answer: a) By checking the page title or URL of the new window


To switch to a window and perform operations without specifying a handle, what should you do?


a) Use driver.switchTo().window() with an index

b) Use JavaScript to directly access the window

c) Selenium does not support switching without a handle

d) Use driver.switchTo().anyWindow()

Answer: c) Selenium does not support switching without a handle

Handling Alerts Using Selenium Java MCQ

 MCQs on Handling Alerts Using Selenium Java

Which Selenium interface is used to handle JavaScript alerts?


a) AlertHandler

b) Alert

c) AlertManager

d) JavaScriptAlert

Answer: b) Alert


How do you switch the WebDriver's context to an alert?


a) driver.switchTo().alert()

b) driver.handle().alert()

c) driver.alert().switch()

d) driver.switchToAlert()

Answer: a) driver.switchTo().alert()


What method is used to accept an alert in Selenium?


a) alert.accept()

b) alert.ok()

c) alert.submit()

d) alert.confirm()

Answer: a) alert.accept()


Which method is used to dismiss an alert?


a) alert.reject()

b) alert.dismiss()

c) alert.cancel()

d) alert.ignore()

Answer: b) alert.dismiss()


To retrieve the text of an alert, which method is used?


a) alert.getText()

b) alert.getAlertText()

c) alert.read()

d) alert.alertText()

Answer: a) alert.getText()


What type of alert requires the user to enter text in an input box?


a) Simple Alert

b) Confirmation Alert

c) Prompt Alert

d) Text Alert

Answer: c) Prompt Alert


How do you enter text into a prompt alert using Selenium?


a) alert.type("text")

b) alert.sendKeys("text")

c) alert.input("text")

d) alert.setText("text")

Answer: b) alert.sendKeys("text")



What will happen if driver.switchTo().alert() is called when there is no alert present?


a) A NoAlertPresentException is thrown

b) The script continues without any exception

c) The method returns null

d) A TimeoutException is thrown

Answer: a) A NoAlertPresentException is thrown


How can you verify if an alert is present on the webpage?


a) Use driver.findElement(By.alert())

b) Use driver.switchTo().alert() and handle NoAlertPresentException

c) Use driver.isAlertPresent()

d) Use alert.isDisplayed()

Answer: b) Use driver.switchTo().alert() and handle NoAlertPresentException


Which WebDriver command would you use to perform both accept and dismiss actions on an alert depending on a condition?


a) alert.acceptOrDismiss(condition)

b) alert.toggle(condition)

c) if (condition) alert.accept(); else alert.dismiss();

d) alert.confirmOrCancel(condition)

Answer: c) if (condition) alert.accept(); else alert.dismiss();


To handle alerts automatically, which Selenium WebDriver method is most commonly used?


a) driver.switchTo().alert().accept()

b) driver.switchTo().alert().dismiss()

c) none

d) a and b

Answer: d) 


When working with alerts, what is the best practice if your test script involves user input?


a) Use Thread.sleep() before switching to the alert

b) Use Explicit Waits to wait for the alert to appear

c) Use Implicit Waits for handling alerts

d) Handle alerts directly without any waits

Answer: b) Use Explicit Waits to wait for the alert to appear


How can you handle an alert if you need to perform an operation right after dismissing it?


a) alert.dismiss(); driver.findElement(By.id("element")).click();

b) alert.accept();

c) alert.dismiss();

d) alert.close(); driver.findElement(By.id("element")).click();

Answer: a) alert.dismiss(); driver.findElement(By.id("element")).click();


If an alert is not handled, what is the likely outcome in a Selenium test script?


a) The test script will continue without any issue

b) The test script will fail with an UnhandledAlertException

c) The test script will throw a NoSuchElementException

d) The test script will automatically accept the alert

Answer: b) The test script will fail with an UnhandledAlertException


Which alert handling method can be used to assert that an alert contains specific text?


a) assertEquals(alert.getText(), "expected text")

b) assertEquals(alert.getAlertText(), "expected text")

c) assertTrue(alert.contains("expected text"))

d) assertTrue(alert.getText().contains("expected text"))

Answer: d) assertTrue(alert.getText().contains("expected text"))


What exception is thrown when you attempt to interact with an alert that is not present?


a) NoSuchElementException

b) AlertNotPresentException

c) NoAlertPresentException

d) UnhandledAlertException

Answer: c) NoAlertPresentException


What Selenium method is used to automate clicking "Cancel" on a confirmation alert?


a) alert.cancel()

b) alert.dismiss()

c) alert.close()

d) alert.reject()

Answer: b) alert.dismiss()

Handling Frames Using Selenium Java MCQ

MCQs on Handling Frames Using Selenium Java

What is the primary reason for handling frames in Selenium WebDriver?

a) To increase the speed of test execution

b) To interact with web elements inside a frame or iFrame

c) To handle browser navigation

d) To manage multiple browser windows

Answer: b) To interact with web elements inside a frame or iFrame

Which method is used to switch to a frame using its index?

a) driver.switchTo().frame(index)

b) driver.switchTo().frameByIndex(index)

c) driver.switchTo().frameByNumber(index)

d) driver.switchTo().frameIndex(index)

Answer: a) driver.switchTo().frame(index)

How can you switch to a frame using its name or ID in Selenium?

a) driver.switchTo().frame("frameNameOrId")

b) driver.switchTo().frameName("frameNameOrId")

c) driver.switchTo().frameByName("frameNameOrId")

d) driver.switchTo().frameNameOrId("frameNameOrId")

Answer: a) driver.switchTo().frame("frameNameOrId")

To switch to a frame using a WebElement, which method should you use?

a) driver.switchTo().frame(WebElement element)

b) driver.switchTo().frameElement(WebElement element)

c) driver.switchTo().frameByElement(WebElement element)

d) driver.switchTo().elementFrame(WebElement element)

Answer: a) driver.switchTo().frame(WebElement element)

Which Selenium method is used to switch back to the main content from a frame?

a) driver.switchTo().defaultContent()

b) driver.switchTo().mainContent()

c) driver.switchTo().parentFrame()

d) driver.switchTo().window()

Answer: a) driver.switchTo().defaultContent()

What method would you use to switch from a nested frame to its parent frame?

a) driver.switchTo().defaultContent()

b) driver.switchTo().parentFrame()

c) driver.switchTo().rootFrame()

d) driver.switchTo().frameParent()

Answer: b) driver.switchTo().parentFrame()

If a webpage has multiple frames, how can you identify the frame index to switch to?

a) By counting the frames in the HTML source starting from zero

b) By using driver.switchTo().frame("frameName")

c) By checking the frame count in the browser's developer tools

d) By using driver.switchTo().defaultContent()

Answer: a) By counting the frames in the HTML source starting from zero

What exception does Selenium throw if you attempt to switch to a frame that does not exist?

a) NoSuchFrameException

b) FrameNotFoundException

c) NoSuchElementException

d) NoFramePresentException

Answer: a) NoSuchFrameException

Which of the following is the correct sequence to switch between multiple frames in a nested structure?

a) driver.switchTo().frame(0).switchTo().frame(1)

b) driver.switchTo().frame(0); driver.switchTo().frame(1);

c) driver.switchTo().defaultContent().switchTo().frame(1)

d) driver.switchTo().parentFrame().switchTo().frame(0)

Answer: b) driver.switchTo().frame(0); driver.switchTo().frame(1);

How can you determine if a WebElement is inside a frame?

a) By inspecting the element's HTML path

b) By checking if NoSuchElementException is thrown

c) By using driver.switchTo().frame()

d) By running the Selenium script and observing its behavior

Answer: a) By inspecting the element's HTML path

If you want to interact with elements outside of a frame after interacting with elements inside a frame, what should you do?

a) Use driver.switchTo().defaultContent()

b) Use driver.switchTo().parentFrame()

c) Use driver.switchTo().frame(0)

d) Use driver.navigate().refresh()

Answer: a) Use driver.switchTo().defaultContent()

When is it necessary to handle frames in Selenium WebDriver?

a) When the web page uses iframes to embed content

b) When dealing with dynamic content on the page

c) When testing multiple browser tabs

d) When handling pop-ups and alerts

Answer: a) When the web page uses iframes to embed content

Which method is used to check if the current driver is already inside a frame?

a) driver.isInFrame()

b) driver.switchTo().getFrame()

c) driver.getFrame()

d) Selenium does not have a direct method to check if you are inside a frame

Answer: d) Selenium does not have a direct method to check if you are inside a frame

What is the best approach to interact with an element located inside a frame?

a) Directly use driver.findElement(By.id("element"))

b) Switch to the frame first and then use driver.findElement(By.id("element"))

c) Refresh the page and try again

d) Use driver.navigate().to("frameUrl")

Answer: b) Switch to the frame first and then use driver.findElement(By.id("element"))

Which type of frame is commonly used to embed content from another domain?

a) iframe

b) frame

c) mainframe

d) subframe

Answer: a) iframe

What happens if you do not switch to the correct frame before interacting with an element inside it?

a) NoSuchFrameException is thrown

b) NoSuchElementException is thrown

c) StaleElementReferenceException is thrown

d) The script continues to run without error

Answer: b) NoSuchElementException is thrown

To handle an element inside a nested frame, which of the following actions is necessary?

a) Use driver.switchTo().parentFrame()

b) Use driver.switchTo().defaultContent()

c) Switch to the parent frame first, then switch to the child frame

d) Switch to the child frame directly

Answer: c) Switch to the parent frame first, then switch to the child frame

Which Selenium method is used to get the count of frames present on a webpage?

a) driver.findElements(By.tagName("iframe")).size()

b) driver.getFramesCount()

c) driver.getFrameElements().size()

d) driver.switchTo().frameCount()

Answer: a) driver.findElements(By.tagName("iframe")).size()

How do you handle frames dynamically in Selenium if the frame ID or name changes frequently?

a) Switch using frame index

b) Use hard-coded frame IDs

c) Use driver.switchTo().frame(WebElement)

d) Refresh the page and try switching again

Answer: a) Switch using frame index

If you want to switch back to the main document after interacting with elements inside multiple frames, which method should you use?

a) driver.switchTo().parentFrame()

b) driver.switchTo().defaultContent()

c) driver.navigate().toMainContent()

d) driver.switchTo().mainDocument()

Answer: b) driver.switchTo().defaultContent()


Synchronization in Selenium MCQ

 MCQs on Synchronization in Selenium

What is the primary purpose of synchronization in Selenium WebDriver?


a) To reduce the execution time of test cases

b) To make the script wait until the web elements are loaded and ready for interaction

c) To make the script run faster

d) To handle exceptions in the code

Answer: b) To make the script wait until the web elements are loaded and ready for interaction


Which of the following is NOT a type of synchronization in Selenium?


a) Implicit Wait

b) Explicit Wait

c) Fluent Wait

d) Static Wait

Answer: d) Static Wait


What does the Implicit Wait in Selenium do?


a) Waits for a specified amount of time for an element to be available

b) Waits for a specified condition to be true

c) Waits for an element to be removed from the DOM

d) Pauses execution for a specified time

Answer: a) Waits for a specified amount of time for an element to be available


Which method is used to set an Implicit Wait in Selenium?


a) driver.manage().timeouts().wait()

b) driver.manage().timeouts().implicitlyWait()

c) driver.manage().timeouts().explicitWait()

d) driver.manage().timeouts().fluentWait()

Answer: b) driver.manage().timeouts().implicitlyWait()


What is the difference between Implicit Wait and Explicit Wait in Selenium?


a) Implicit Wait is applied globally, Explicit Wait is applied only to specific elements

b) Implicit Wait is faster than Explicit Wait

c) Explicit Wait is applied globally, Implicit Wait is applied only to specific elements

d) There is no difference

Answer: a) Implicit Wait is applied globally, Explicit Wait is applied only to specific elements


Which class is used in Selenium to implement Explicit Wait?


a) WebDriverWait

b) FluentWait

c) ThreadWait

d) ConditionWait

Answer: a) and b 


How can you specify a condition for an Explicit Wait in Selenium?


a) new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.visibilityOfElementLocated(By.id("elementId")))

b) new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.id("elementId")))

c) new WebDriverWait(driver, 10).until(ExpectedConditions.textToBePresentInElement(By.id("elementId"), "text"))

d) All of the above

Answer: d) All of the above


What is Fluent Wait in Selenium?


a) It is a type of Explicit Wait with a polling interval

b) It waits indefinitely for an element to be available

c) It is a combination of Implicit and Explicit Waits

d) It waits for a fixed amount of time

Answer: a) It is a type of Explicit Wait with a polling interval


Which method is used in Fluent Wait to set the frequency with which to check the condition?


a) pollingEvery()

b) withTimeout()

c) until()

d) ignoring()

Answer: a) pollingEvery()


What is the default polling frequency of Fluent Wait if not set explicitly?


a) 250 milliseconds

b) 500 milliseconds

c) 1 second

d) 5 seconds

Answer: b) 500 milliseconds


Which wait type in Selenium is most effective for handling dynamic elements that load at different times?


a) Implicit Wait

b) Explicit Wait

c) Fluent Wait

d) Static Wait

Answer: c) Fluent Wait


How does Explicit Wait differ from Fluent Wait in Selenium?


a) Explicit Wait only waits for elements to be visible, Fluent Wait can wait for any condition

b) Explicit Wait has a fixed timeout, Fluent Wait has customizable polling intervals and conditions

c) Fluent Wait is more efficient than Explicit Wait

d) There is no difference

Answer: b) Explicit Wait has a fixed timeout, Fluent Wait has customizable polling intervals and conditions


What exception does Fluent Wait ignore by default?


a) TimeoutException

b) NoSuchElementException

c) ElementNotVisibleException

d) StaleElementReferenceException

Answer: b) NoSuchElementException


Which method would you use to make Selenium wait until a specific element is visible on the page?


a) ExpectedConditions.visibilityOfElementLocated()

b) ExpectedConditions.elementToBeClickable()

c) ExpectedConditions.presenceOfElementLocated()

d) ExpectedConditions.invisibilityOfElementLocated()

Answer: a) ExpectedConditions.visibilityOfElementLocated()


What is the default timeout for Implicit Wait in Selenium if not explicitly set?


a) 0 seconds

b) 10 seconds

c) 30 seconds

d) 60 seconds

Answer: a) 0 seconds


Which wait type in Selenium is generally discouraged due to its static nature and lack of flexibility?


a) Implicit Wait

b) Explicit Wait

c) Fluent Wait

d) Thread.sleep()

Answer: d) Thread.sleep()


How would you set an Explicit Wait to wait for a maximum of 15 seconds for an element to become clickable?


a) new WebDriverWait(driver, Duration.ofSeconds(15)).until(ExpectedConditions.elementToBeClickable(By.id("elementId")));

b) driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));

c) Thread.sleep(15000);

d) new WebDriverWait(driver, 15).until(ExpectedConditions.visibilityOfElementLocated(By.id("elementId")));

Answer: a) new WebDriverWait(driver, Duration.ofSeconds(15)).until(ExpectedConditions.elementToBeClickable(By.id("elementId")));


When should you use a Fluent Wait over an Explicit Wait?


a) When you need to wait for a condition and customize polling intervals

b) When you want to set a global wait time for all elements

c) When you want a faster wait time

d) When handling elements that are always present

Answer: a) When you need to wait for a condition and customize polling intervals


Which wait strategy in Selenium is best for handling AJAX-based elements that appear and disappear dynamically?


a) Implicit Wait

b) Explicit Wait

c) Fluent Wait

d) Static Wait

Answer: c) Fluent Wait

git commands MCQ

 Here are some multiple-choice questions (MCQs) on Git commands relevant for Selenium: 1. Which Git command is used to clone a remote reposi...