Having trouble clicking on an element due to a drop-down menu covering all other elements.
Incorporating Selenium in Visual Studio, I am attempting to create a testcase where I initially click on a checkbox in a drop-down menu and then proceed to click on another element outside the drop-down. However, the drop-down menu fails to close itself after clicking on the first checkbox.
Manually closing this drop-down in the web browser only requires hitting Esc or clicking somewhere outside the menu. But automation of this process seems to be ineffective.
I attempted to send the Esc key in the script as follows:
Actions action = new Actions(driver);
action.SendKeys(OpenQA.Selenium.Keys.Escape);
This method did not work as expected. Instead of producing an error for sending the Esc key, it resulted in a timeout when trying to click on the obscured element:
OpenQA.Selenium.ElementClickInterceptedException : Element <div class="mat-radio-outer-circle"> is not clickable at point (116,608) because another element <div class="cdk-overlay-backdrop cdk-overlay-transparent-backdrop cdk-overlay-backdrop-showing"> obscures it
Another attempt involved clicking outside the drop-down instead of using the Esc key:
wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[3]/div[3]"))).Click();
Unfortunately, this approach did not yield results in Visual Studio, even though it worked in Selenium IDE by simply using the 'click' command with //div[3]/div[3]
as the target.
Various methods such as using the select function in IDE and utilizing firebug have been explored to identify elements outside the drop-down menu. However, none of them proved fruitful besides the specific clickable element mentioned earlier.
To sum it up:
Please confirm if my code for sending "Esc" is correct.
Why does Visual Studio struggle to recognize and click on
//div[3]/div[3]
, i.e., outside the drop-down, whereas it is feasible in Selenium IDE?Are there alternative ways to close the drop-down menu efficiently?
I've come across suggestions about clicking on obscured elements using JavaScript, but I lack guidance on how to implement this in C#. Any recommendations on accomplishing this task?