When selenium tries to click a button, web site deleting a div above, and selenium clicks the element under the element that I wanted to click. I try to click with XPath, CSS selector, and the class name and none of them work. Also, I tried action chains to click but not worked.
And before clicking, I can confirm the selected element is the right element.
var element=driver.FindElements(By.ClassName("warning"))[0];
Debug.WriteLine(element.Text);
This writes the right element to the output.
-Here is the code By.ClassName:
driver.FindElements(By.ClassName("warning"))[0].Click();
The element under the right element does not have a "warning" class but it's still clicking on that element.
The page is basically like this:
<div id="maindiv">
<div class="the div that will delete"></div>
<button class="warning"></button>
<button class="second"></button>
<button class="third"></button>
<button class="fourth"></button>
</div>
Basically, I'm trying to click the "warning" button but the "third" button receiving the click. What should I do?