admin管理员组文章数量:1336592
I have a problem with selenium test using java, I want to upload a profile photo but I found errors. Everything works well at first, the photo is downloaded but it does not appear on the screen and the validation button is not clickable knowing that all the paths are 100% correct. I tried several solutions like forcing the click, checking that the button is no longer deactivated,I increased the implicit time but still it doesn't work. This is the response I receive when I run my code: File sent : C:\Users\KATANA\Desktop Image loaded correctly: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=
.openqa.selenium.TimeoutException: Expected condition failed: waiting for wattzhub.account.UpdatePage$$Lambda/0x000001b40122a6f8@5a62b2a4 (tried for 10 second(s) with 500 milliseconds interval)
I hope you can help me resolve this problem and thank you very much in advance.
public void changeProfilePicture(String imagePath) {
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
By modifyButton = By.xpath("//button[@class='p-element p-button-outlined p-button-secondary ml-auto mr-auto mt-3 mb-3 p-button p-component']");
WebElement modifyButtonElement = wait.until(ExpectedConditions.elementToBeClickable(modifyButton));
modifyButtonElement.click();
By pictureDownload = By.xpath("//div[@class='modal-content']//span[@class='input-browse']");
WebElement pictureDownloadElement = wait.until(ExpectedConditions.visibilityOfElementLocated(pictureDownload));
pictureDownloadElement.click();
By modalContent = By.xpath("//div[@class='modal-content']");
WebElement modalElement = wait.until(ExpectedConditions.visibilityOfElementLocated(modalContent));
delay(1000);
By fileInput = By.id("file-upload");
WebElement fileInputElement = wait.until(ExpectedConditions.presenceOfElementLocated(fileInput));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].style.display='block'; arguments[0].style.opacity='1';", fileInputElement);
fileInputElement.sendKeys(imagePath);
System.out.println("File sent : " + imagePath);
By imageElement = By.xpath("//img[contains(@class, 'source-image')]");
wait.until(ExpectedConditions.presenceOfElementLocated(imageElement));
WebElement image = driver.findElement(imageElement);
js.executeScript("arguments[0].style.visibility='visible';", image);
wait.until(driver -> {
String visibility = image.getCssValue("visibility");
return visibility.equals("visible");
});
// Validez l'attribut src
String srcValue = image.getAttribute("src");
if (srcValue.startsWith("data:image/png;base64,")) {
System.out.println("Image loaded correctly: " + srcValue);
} else {
System.out.println("Image not loaded or invalid src.");
}
}
本文标签:
版权声明:本文标题:javascript - org.openqa.selenium.TimeoutException: Expected condition failed: waiting for wattzhub.account.UpdatePage$$Lambda - 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742409727a2469543.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论