Search code examples
angularseleniumdropdown

Not able to click out side of the drop-down - selenium angular


Angular 11.0.2 web application

To check if validation message is displayed or not when value is not selected from the drop-down, I am clicking outside of the drop-down, but getting ElementNotInteractableException

Also In the inspector window, I am not able to inspect any of the elements when the drop-down is visible. Getting div.cdk-overlay-backdrop cdk-overlay-transparent-backdrop cdk-overlay-backdrop-showing when trying to inspect.

Please find the below screenshot for same.

enter image description here


Solution

  • There are two ways of handling it, either you can click outside of the drop down using a different elements tag name or use seleniums mouse click action using co-ordinates (Ex: 0,0) whivh is outside of the drop down.

    1. driver.findElement(By.tagName("body")).click();

    2. Actions action = new Actions(driver); action.moveByOffset(0, 0).click().build().perform();