Pat
Pat

Reputation: 727

Checkbox does not get checked

Hi I am automating a webpage which contains multiple checkbox. It clicks on a some checkbox and misses some checkbox. This is my code. Should I put a wait statement before the click to avoid this problem.

  IWebElement ClickElement = Wait.Until((d) => webDriver.FindElement(By.Id(parameter1)));
  ClickElement.Click();

Upvotes: 1

Views: 940

Answers (1)

Hari Reddy
Hari Reddy

Reputation: 3858

Can you try making this change in your code -

In wait until function you are checking if the element exists by using findElement(By.Id(parameter1))

After finding the WebElement check if this is displayed by using isDisplayed() method with in the waitUntil function.

You can also check if it has already checked or not by using isSelected() method.

Upvotes: 1

Related Questions