meethods Flashcards
findElement() method
a convenient way to locate an element on the web page
code for findElement()?
WebElement findElement(By by)
What happens if the findElement() does not find the element
runtime exception NoSuchElementException
Code for finding list of elements?
java.util.List findElements(By by)
findElements()
For finding multiple elements matching the same locator criteria on a web page
What happens if one element is found? using find elements()
if there are multiple WebElements present that satisfy the locating mechanism, all of them are returned to the caller in a list.
What happens if no element is found using findElements()
if no element is found, an empty list is returned a
What are the different ways to find elements?
There are 8
ID
Name
ClassName
TagName
LinkText
PartialLinkText
XPath
CSS Selector.
Which is faster xpath or css?
css selector
How do you get this text?
name = “q”
getting q text
<input></input>
use getAttribute() method
getLocation()
used to get the relative position of an element where it is rendered on the web page
getSize()
return the width and height of the rendered WebElement.
what is used to get css? why useful?
getCssValue()
This is useful when you want to validate the CSS styles that are applied to your WebElements through your test scripts.
What css things can you get with getCssValue?
CSS properties can be font-family, background-color, color,