Waits

Home >> Tags >> Waits

How to check if an element is present with protractor?

Before performing an action with an element, we just need to make sure of the presence of the element on the web page. When we try to interact with an element, if it is not present, it will throw an error/exception, so it is always important checking for the presence of the element.

Example : - When we click a Submit button, we know that we have to wait a second or two for something to happen. Here before trying to test the response, we can always check for element/s that are expected.

WebDriver Waits Examples

We can use WebDriverWait class in many different cases. When ever we need to perform any operation on element, we can use Webdriver wait to check if the element is Present or visible or enabled or disabled or Clickable etc.

NOTE - There are changes with Waits and Timeouts in Selenium 4, please check Updated Webdriver waits and timeouts.

We will look into different examples for all the above scenarios:

isElementPresent:

Synchronization in Selenium Webdriver

It is a mechanism which involves more than one components to work parallel with Each other.

Generally in Test Automation, we have two components
1. Application Under Test
2. Test Automation Tool.

Both these components will have their own speed. We should write our scripts in such a way that both the components should move with same and desired speed, so that we will not encounter "Element Not Found" errors which will consume time again in debugging.

Synchronization can be classified into two categories: