[Tutorial] Troubleshooting Tests With CDP And BiDi APIs In Selenium 4 ▶️

Do you know the most awaited feature in Selenium 4? Watch this video demonstrating one of the most exciting features introduced in Selenium 4, i.e., the BiDirectional APIs, also referred to as the CDP APIs.

:loudspeaker: 𝑰𝒏 𝒕𝒉𝒊𝒔 𝒗𝒊𝒅𝒆𝒐 𝒐𝒏 𝒕𝒓𝒐𝒖𝒃𝒍𝒆𝒔𝒉𝒐𝒐𝒕𝒊𝒏𝒈 𝒕𝒆𝒔𝒕𝒔 𝒊𝒏 𝑺𝒆𝒍𝒆𝒏𝒊𝒖𝒎 𝟒, 𝑨𝒏𝒕𝒐𝒏 𝑨𝒏𝒈𝒆𝒍𝒐𝒗 (@𝒂𝒏𝒈𝒆𝒍𝒐𝒗𝒔𝒕𝒂𝒏𝒕𝒐𝒏), 𝑪𝑻𝑶 𝒂𝒏𝒅 𝑪𝒐-𝒇𝒐𝒖𝒏𝒅𝒆𝒓 𝒐𝒇 𝑨𝒖𝒕𝒐𝒎𝒂𝒕𝒆 𝑻𝒉𝒆 𝑷𝒍𝒂𝒏𝒆𝒕 𝑳𝒕𝒅, 𝒆𝒙𝒑𝒍𝒂𝒊𝒏𝒔 𝒉𝒐𝒘 𝑪𝑫𝑷 𝒉𝒂𝒔 𝒃𝒆𝒄𝒐𝒎𝒆 𝒂 𝒍𝒐𝒕 𝒎𝒐𝒓𝒆 𝒑𝒐𝒕𝒆𝒏𝒕 𝒘𝒊𝒕𝒉 𝒕𝒉𝒆 𝒂𝒅𝒅𝒊𝒕𝒊𝒐𝒏 𝒐𝒇 𝒕𝒉𝒆 𝑪𝑫𝑷 𝑨𝑷𝑰𝒔 𝒂𝒏𝒅 𝒉𝒐𝒘 𝒘𝒆 𝒄𝒂𝒏 𝒍𝒆𝒗𝒆𝒓𝒂𝒈𝒆 𝒕𝒉𝒆𝒎 𝒘𝒊𝒕𝒉 𝒍𝒊𝒗𝒆 𝒆𝒙𝒂𝒎𝒑𝒍𝒆𝒔.

The new bidirectional APIs will allow you to perform a variety of activities, such as:

:small_orange_diamond: Mutation observation

Mutation observation is the ability to record DOM events of interest. For example, you might want to know if an element’s property value has changed. Previously, the approach was to query the part indefinitely until the desired change occurred. You can now observe changes in the DOM and assert over them when an incoming event alerts you to an expected change.

:small_orange_diamond: Check JavaScript exceptions

We can now listen for JavaScript exceptions and set up callbacks to handle the exception details.

:small_orange_diamond: Listen to events from console.log

Logs are essential in testing, and getting logs from the browser console hasn’t always been the most straightforward task with Selenium testing. It is possible to obtain console logs using the bidirectional APIs to understand better how our application under test is performing. As a result, we can now perform assertions on the console log messages.

1 Like