Many a times I wondered what's the difference between the two functions. Here is what I have:
isElementPresent() - This method basically tests if the element we are looking for is present somewhere on the page.
isVisible() - looks for display: none style tag - this might throw a null pointer if we aren't careful...thus to see if an element is visible first check if the element is present using isElementPresent() method. Then try checking if the element is visible!
Observe that isElementPresent() won't mind even if our element is not visible.
For ex:
lets say the below is the html code for a component on my test application:
now if you test the above component with
selenium.isElementPresent("testinput") - returns true!
selenium.isVisible("testinput") - returns false!
isElementPresent() - This method basically tests if the element we are looking for is present somewhere on the page.
isVisible() - looks for display: none style tag - this might throw a null pointer if we aren't careful...thus to see if an element is visible first check if the element is present using isElementPresent() method. Then try checking if the element is visible!
Observe that isElementPresent() won't mind even if our element is not visible.
For ex:
lets say the below is the html code for a component on my test application:
now if you test the above component with
selenium.isElementPresent("testinput") - returns true!
selenium.isVisible("testinput") - returns false!
Comments
machine learning course training in Guwahti