There are several CSS selectors, but I am
going to introduce you to a few of them as we gradually build our case to more
complex examples.
(a)Element
Selectors - Element selectors use the name of the
element(tagname) to locate the element.
EX:
<input id="firstName"
name="fname"
type="text" value="" />
driver.FindElement(By.CSSSelector("input"));
(b)ID
Selectors - ID selectors use place a hash or pound
sign in front of the id value of that element
EX:
<input id="firstName" name="fname" type="text" value="" />
driver.FindElement(By.CSSSelector("input#firstName"));
(c)Class
Selectors -Class selectors place a dot in front of
the class attribute value of that element
EX:
<input id="firstName" class="btCls" type="text" value="" />
driver.FindElement(By.CSSSelector("input.btCls"));
0 comments