Professional Documents
Culture Documents
Day4 CSSSelectors Attributes Waits
Day4 CSSSelectors Attributes Waits
no: +91-9703093014
To check this, we can check the css values that are changing when we perform mouse hover on the
element.
In the below example program, we are ge ng the bu on color. When we get the color value, it will
always return color in ' RGB (Red, Green and Blue). These values range from 0 to 255 gives a total of
more than 16 million di erent colours with (256 x 256 x 256).
In getCssValue_Bu onFontSize', we are ge ng the bu on font size which will return '11px'. And in
'getCssValue_Bu onFontWeight' test, we are ge ng the font-weight of the bu on. It will return 400
for font-weight: normal, and 700 for font-weight: bold. Numeric font weights for fonts that provide
more than normal and bold.
For example, when you enter a text in to the textbox in a web applica on. Your requirement is to
verify whether the value entered properly or not in to the textbox how can you get the value?
You can use getA ribute() method to get the a ribute value when you provide a ribute name
to this method,
tti
tti
tt
tt
tt
tt
ti
tt
ff
tt
ti
tti
tti
tt
tti
tti
tt
tt
tt
tt
tt
ti
tt
tt
tt
As shown here:
ti
ti
tt
fl
ti
tt
ti
ti
tt
ti
ti
ti
tt
ti
ti
tt
ti
fi
Abhilash Reddy Mamidi Mobile.no: +91-9703093014
a. Implicit wait:
Implicit waits will be in place for the en re me the browser is open. This means selenium will wait
maximum of implicit wait me before throwing an excep on error, but incase that element exists
before that maximum me also, s ll it will be wai ng for that much me.
Logic:-Selenium checks the control in rst go, incase it is not able to nd the control it will wait for the
given implicit me, and then try again, a er the end of the wait me to look for the control before
throwing an excep on. By default its value is 0.
It accepts 2 params, me to wait = 30 and TimeUnit which is seconds in our case. Thus here, It asks
selenium to wait for 30 seconds for all the controls before throwing an error.
b. Explicit Wait:
We are explicitly making the execu on of selenium code to wait, for a certain condi on to occur
before, proceeding further in the code.
ti
ti
ti
ti
ti
ti
ti
ti
fi
ti
ft
ti
ti
ti
ti
ti
fi
ti
Abhilash Reddy Mamidi Mobile.no: +91-9703093014
Answer is strict no, and we would only apply explicit wait on this(slower) control with an expected
condi on.
Logic:-
It is applicable to the given control and waits to the maximum amount of me or move forward incase
the given condi on is met.
Differences:
1) Implicit wait is set for the entire duration of the webDriver object. Suppose , you want to wait for a
certain duration, let's say 5 seconds before each element or a lot of elements on the webpage load. Now,
you wouldn't want to write the same code again and again. Hence, implicit wait. However, if you want
to wait for only one element, use explicit.
2) You not only need web element to show up but also to be clickable or to satisfy certain other
property of web elements. Such kind of flexibility can be provided by explicit wait only. Specially
helpful if dynamic data is being loaded on webpage. You can wait for that element to be developed (not
just show up on DOM) using explicit wait.
ti
ti
ti
ti
ti
ti