Selenium WebDriver Quiz
Question 1
|
In webdriver, what is the method that counts the number of
elements?
A
|
driver.getCountOfElements()
|
B
|
driver.findElement(By.id("search")).getCount()
|
C
|
driver.findElements(By.id("search")).size()
|
D
|
driver.findElements(By.id("search")).length()
|
Question 2
|
In
webdriver, deselectAll() is a valid command
A
|
True
|
B
|
False
|
Question 3
|
Consider the following html snippet
<ul>
<li>Firefox</li>
<li>Google Chrome</li>
<li>Internet Explorer</li>
<li>Opera</li>
<li>Safari</li>
</ul>
Which CSS selector is a valid statement to select Opera?
<ul>
<li>Firefox</li>
<li>Google Chrome</li>
<li>Internet Explorer</li>
<li>Opera</li>
<li>Safari</li>
</ul>
Which CSS selector is a valid statement to select Opera?
A
|
css = li.contains("Opera")
|
B
|
css = ul.li(4)
|
C
|
css = ul > li:nth-of-type(4)
|
D
|
css = ul > li:nth-of-type(3)
|
E
|
css = ul.li:nth-child(4)
|
Questions 4:
In webdriver, which of the following commands retrieves the text
of a html element?
A
|
selectText()
|
B
|
getText()
|
C
|
getElementText()
|
D
|
getText(element)
|
Question 5
|
In webdriver, which of the following is a valid select statement
that selects a value from a drop down element?
A
|
selectByIndex()
|
B
|
selectByVisibleText()
|
C
|
selectByValue()
|
D
|
all above
|
E
|
none of above
|
Qu
estion 6
|
In WebDriver, which command can be used to enter values onto
text boxes? Select the best answer
A
|
type()
|
B
|
selenium.type()
|
C
|
driver.type()
|
D
|
sendKeys()
|
E
|
sendKeys("text")
|
Question 7
|
In webdriver, which methods navigates to a URL?
A
|
goToUrl("url")
|
B
|
navigate.to("url")
|
C
|
getUrl("url")
|
D
|
get("url")
|
Q
uestion 8
|
What is the output of the following statement?
<div>
<span id="name">Name 1</span>
<span class="name">Name 2</span>
</div>
driver.findElement(By.cssSelector("#name"));
<div>
<span id="name">Name 1</span>
<span class="name">Name 2</span>
</div>
driver.findElement(By.cssSelector("#name"));
A
|
Output is Name 1
|
B
|
Output is Name 2
|
C
|
CSS selector syntax is incorrect
|
Question 9
|
Implicit wait time is applied to all elements in your script and
Explicit wait time is applied only for particular specified element.
A
|
True
|
B
|
False
|
Question 10
|
In webdriver, selectAllOptions() is a valid command.
A
|
Ture
|
B
|
False
|
Question 11
|
Selenium IDE is supported by which browser?
A
|
Internet Explorer
|
B
|
Mozilla Firefox
|
C
|
Google Chrome
|
D
|
Safari
|
E
|
All Of Above
|
uestion 12
|
In webdriver, which command takes you forward by one page on the
browser’s history?
A
|
navigate.forward()
|
B
|
Navigate.forward()
|
C
|
navigate().forward()
|
D
|
Navigate.forward
|
E
|
navigate_forward()
|
Question 13
|
Consider the following code snippet
WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.presenceOfElementLocated(by));
This is an example of an implicit wait.
WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.presenceOfElementLocated(by));
This is an example of an implicit wait.
A
|
True
|
B
|
False
|
Question 14
|
Which WebDriver method is used to change focus to an alert, a
frame or a browser window?
A
|
changeFocus()
|
B
|
setFocus()
|
C
|
switchTo()
|
D
|
changeTo()
|
Question 15
|
In webdriver, which method closes the open browser?
A
|
quit()
|
B
|
terminate()
|
C
|
shutdown()
|
D
|
close()
|
Question 16
|
Consider the following HTML code snippet
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
driver.findElement(By.xpath("//table/tr[1]/td")).getText();
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
driver.findElement(By.xpath("//table/tr[1]/td")).getText();
A
|
The above statement returns 1
|
B
|
The above statement returns 3
|
C
|
The xpath query is incorrect
|
D
|
webdriver statement is incorrect
|
uestion 17
|
The following codes both print: Welcome to TestingExcellence.com
<html>
<head>
<title>Welcome to TestingExcellence.com</title>
</head>
<body>
</body>
</html>
System.out.println(driver.getTitle());
System.out.println(driver.findElement(By.tagName("title")).getText())
<html>
<head>
<title>Welcome to TestingExcellence.com</title>
</head>
<body>
</body>
</html>
System.out.println(driver.getTitle());
System.out.println(driver.findElement(By.tagName("title")).getText())
A
|
True
|
B
|
False
|
1. Which of these WebDriver interface methods is used to
open a URL in the browser?
get
navigate().to
Any of the above
None of the above
navigate().to
Any of the above
None of the above
2. What is the difference between WebDriver close and quit methods?
Nothing, these methods are interchangeable.
close method clears the browser memory and the quit method closes the browser window.
close method closes the browser but the quit method additionally removes the connection to the server.
close method closes the main browser window but the quit method closes all the browser windows including popups.
close method clears the browser memory and the quit method closes the browser window.
close method closes the browser but the quit method additionally removes the connection to the server.
close method closes the main browser window but the quit method closes all the browser windows including popups.
3. When invoked on a web element, what does the submit method do?
It is used to submit a form and it works on
any web element.
It is used to submit a form but it works only on the web element whose type is "submit".
It is the same as the click method.
There is no submit method for a web element.
It is used to submit a form but it works only on the web element whose type is "submit".
It is the same as the click method.
There is no submit method for a web element.
4. Which WebDriver method is used to change focus to an alert, a web element or a browser window?
changeFocus
switchTo
goTo
setFocus
switchTo
goTo
setFocus
5. What functionality does WebDriver support on browser cookies?
add and delete an individual cookie
delete all cookies
any of the above
none of the above
delete all cookies
any of the above
none of the above
6. What is the scope of an implicit wait?
All instances of WebDriver
Current WebDriver instance
Current expected condition
Current web element
Current WebDriver instance
Current expected condition
Current web element
Score is 0/ 6.
Q16 answer
ReplyDeleteA
Delete@Amandeep Singh The above statement returns 1
ReplyDeleteWhere is the answers for these? questions are awesome
ReplyDeleteAnswer for 8th question pls
ReplyDeleteanswer is : Name 1
Deleteanswer is : Name 1
ReplyDelete