Friday, August 23, 2024

WebElement methods MCQ

 Absolutely, here are some multiple-choice questions (MCQs) focusing on Selenium WebElement methods:



Which method is used to enter text into a text field in Selenium WebElement?

a) sendText()

b) sendKeys()

c) enterText()

d) type()


Answer: b) sendKeys()


What does the click() method do when used on a Selenium WebElement?

a) Enters text into a text field

b) Submits a form

c) Simulates a mouse click on the element

d) Clears the text of an input field


Answer: c) Simulates a mouse click on the element


Which method would you use to clear the text from an input field?

a) clearText()

b) reset()

c) clear()

d) deleteText()


Answer: c) clear()


How can you retrieve the text content of a WebElement?

a) getTextContent()

b) getValue()

c) getText()

d) retrieveText()


Answer: c) getText()


To determine if a WebElement is currently displayed on the web page, which method should be used?

a) isDisplayed()

b) isVisible()

c) isPresent()

d) isEnabled()


Answer: a) isDisplayed()


Which method checks if a WebElement is enabled?

a) isDisplayed()

b) isClickable()

c) isActive()

d) isEnabled()


Answer: d) isEnabled()


To verify if a WebElement is selected, such as in the case of a checkbox or radio button, which method is used?

a) isChecked()

b) isSelected()

c) isMarked()

d) isToggled()


Answer: b) isSelected()


Which method retrieves the value of a specified attribute of a WebElement?

a) getAttributeValue()

b) fetchAttribute()

c) getAttribute()

d) retrieveAttribute()


Answer: c) getAttribute()


What does the getTagName() method return?

a) The text of an element

b) The name of the WebElement

c) The tag name of the WebElement

d) The attribute of an element


Answer: c) The tag name of the WebElement


Which method is used to submit a form using a WebElement?

a) submit()

b) send()

c) formSubmit()

d) sendForm()


Answer: a) submit()


If you want to get the CSS value of a particular property of a WebElement, which method would you use?

a) getCssValue()

b) getStyle()

c) getCss()

d) fetchCssValue()


Answer: a) getCssValue()


To find a child element within a parent WebElement, which method should you use?

a) findChildElement(By locator)

b) findElement(By locator)

c) findElementWithin(By locator)

d) locateElement(By locator)


Answer: b) findElement(By locator)


Which method is used to find multiple WebElements on a page that match a given criteria?

a) findAllElements(By locator)

b) getElements(By locator)

c) findElements(By locator)

d) locateElements(By locator)


Answer: c) findElements(By locator)


What is the return type of the findElements(By locator) method?

a) WebElement

b) List<WebElement>

c) Set<WebElement>

d) Array<WebElement>


Answer: b) List<WebElement>


To get the dimensions and position of a WebElement on the web page, which method is used?

a) getLocation()

b) getSizeAndLocation()

c) getRect()

d) getDimensions()


Answer: c) getRect()


Which method retrieves the size (width and height) of a WebElement?

a) getSize()

b) getDimension()

c) getBoundingBox()

d) getArea()


Answer: a) getSize()


Which WebElement method helps to get the X and Y coordinates of an element on the page?

a) getPosition()

b) getLocation()

c) getCoordinates()

d) getXY()


Answer: b) getLocation()


What does the isDisplayed() method return if a WebElement is hidden using CSS?

a) true

b) false

c) null

d) An exception is thrown


Answer: b) false


No comments:

Post a Comment

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...