I am trying to set an attribute value for all same kind of <img> tag in My website e.g
<img src="images/temp/advertisement.png">
and i wanted to set style="display:none" so I will be able to hide them.
I have tried following method -
List<WebElement> element = driver.findElements(By.tagName("img"));
for(WebElement e:element)
{
if(e.getAttribute(src).contains("images/temp/advertisement.png"))
{
jse.executeScript("document."+e+".setAttribute('style', 'display: none;')");
}
}
but getting an error
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected token [
Is any one help what is wrong here or what other I can do?