Seleniumでclick()ができない
温馨提示:
本文最后更新于 2024年04月12日,已超过 37 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
チェックボックスをクリックしようとしていますが、クリックできません。
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);
}
現在、JavaScriptでclick()を実行しようとしています。
org.openqa.selenium.ElementClickInterceptedException: element click intercepted:
そこでJavaScriptを使って試してみます。 Javascriptでクリックしようとすると、要素はクリックされず、次の変数participantTextが表示されないというエラーが発生します。おらず、TextArea が表示されていないためです。
「その他」次にどうすればよいですか?
正文到此结束
- 本文标签: 家庭宠物
- 本文链接: https://www.coder6.net/article/2608
- 版权声明: 本文由蚂蚁原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权