I am trying to click a checkbox and I am not able to do it.
try {
WebElement primaryParticipant = driver.findElement(By.xpath("//*[@id="searchable-list-input-primaryParticipantSearchable"]"));
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
WebElement other = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//li[5]/mat-checkbox[@class="mat-checkbox chp-ds pt-75 mat-primary ng-untouched ng-pristine ng-valid"]")));
((JavascriptExecutor)driver).executeScript("arguments[0].click();", other);
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", primaryParticipant); //Scroll into the Additional Participants Section
captureImage();
Thread.sleep(2000);
WebElement participantText = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class="mat-form-field-infix ng-tns-c14-7"]/textarea")));
participantText.click();
Thread.sleep(2000);
participantText.sendKeys("Automation Test");
Thread.sleep(2000);
captureImage();
} catch (Exception e) {
captureImage();
throw new AssertionError("Could not select Other on the checkbox or write on it.", e);
}
Right now I am trying to do the click() with Javascript because I found the error related to org.openqa.selenium.ElementClickInterceptedException: element click intercepted:
So I am trying with Javascript. When I try to do the click with Javascript the element is not being clicked and I am getting an error of the next variable participantText that it is not visible. This is because the checkbox of Other was not clicked and the TextArea is not visible.
How can I click on Other?