example of assert
TRANSCRIPT
8/18/2019 Example of Assert
http://slidepdf.com/reader/full/example-of-assert 1/2
Example Of Assert.assertFalse Assertion In Selenium WebDriver With TestNG
When you are or!in" ith selenium eb#river$ you must be aare about#i%erent !in# of assertions hi&h are available. If you have a enou"h
!nole#"e about eb#river assertions$ 'ou &an &reate very e%e&tive test&ases for your test s&enarios. assertE(uals$ assertNotE(uals an#assertTrue assertions are alrea#yexplaine# in my previous posts. No let e try to un#erstan# assertFalseassertion for selenium eb#river.
Assert.assertFalse)&on#ition* AssertionIt ill &he&! boolean value returne# by &on#ition an# ill pass if returne#value is +False+. If returne# value is pass then this assertion ill fail an# s!ipexe&ution from &urrent test metho#. Syntax for assertFalse assertion is asbello.
Assert.assertFalse)&on#ition*,
In sort$ assertFalse an# assertTrue assertions are opposite to ea&h other.When you ants to assert +True+ value - you &an use assertTrue assertion.An# hen you ants to assert false value - you &an use assertFalse assertionin your selenium eb#river test.
et e try to use assertFalse assertion ith simple example. Supposin" ehave to &he&!boxs on pa"e one from them is &he&!e# an# another one isnot &he&!e#. et e apply assertFalse assertion on both of these &he&! boxesfor its &he&!e# status.
/epla&e bello "iven example metho#s ith example of T0IS 1AGE. an# runit ith testn".xml as #es&ribe# on that post.
WebElement &h!2$ &h!3, 45efore6lass publi& voi# loa#7url)*8 #river."et)+http9::only-testin"-blo".blo"spot.in:3;2<:;3:attributes.html+*, &h!2 = #river.>n#Element)5y.xpath)+::input?4name=@option2@+**, &h!3 = #river.>n#Element)5y.xpath)+::input?4name=@option3@+**,
B::Assertion Cetho# - ill Fail 4Test publi& voi# assertfalse2)* 8 System.out.print)+n+&h!2.isSele&te#)**, Assert.assertFalse)&h!2.isSele&te#)**, B ::Assertion Cetho# - ill 1ass
8/18/2019 Example of Assert
http://slidepdf.com/reader/full/example-of-assert 2/2
4Test publi& voi# assertfalse3)* 8 System.out.print)+n+&h!2.isSele&te#)**, Assert.assertFalse)&h!3.isSele&te#)**, B
In this &ase$ assertfalse2)* metho# ill fail be&ause it is alrea#y &he&!e#so &h!2.isSele&te#)* ill return true value. assertfalse3)* metho# ill passbe&ause 3n# &he&!box is not &he&!e# so it ill return false value. Exe&utionresult ill loo!s li!e bello.