After successfully utilizing the JavaScript-executer to locate the ImageElement
, I encountered an error when attempting to extract the URL for downloading the image.svg. The error message reads "NoSuchElementException." Below is a snippet of my code:
((JavascriptExecutor)driver).executeScript("window.open('https://www.lambdatest.com/selenium-automation/','_blank');");
wait.until(webDriver -> ((JavascriptExecutor) webDriver).executeScript("return document.readyState").equals("complete"));
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
JavascriptExecutor js = (JavascriptExecutor) driver;
By Image=By.xpath("//img[@title='Jenkins']");
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
// The commented-out section below results in an Error
/*WebElement ImageElemnt =driver.findElement(Image);
String src = ImageElemnt.getAttribute("src");
System.out.println(src);*/
wait.ignoring(NoSuchElementException.class).until(ExpectedConditions.invisibilityOfElementLocated(Image))