Your image element is in iFrame
, So first you need to switch into related iFrame
and then you can perform desired actions on that element.
There are following ways provided in the Selenium to work with iframes :
Switch using frame Index
driver.switchTo().frame(0); // used indexes 0,1... as number of frames you have in webpage
Switch using frame id
(if your iframe have id attribute)
driver.switchTo().frame(frame_id);
Switch using webelement
(locate the frame as webelement)
WebElement frame = driver.findElement(By.xpath("frame_xpath"));
driver.switchTo().frame(frame);
Apart from these you can also use ExplicitWait conditions to switch into frame e.g.
new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("your_frame_id")));
In your case you have to switch in and perform your actions e.g. :
driver.switchTo().frame(0);
driver.findElement(By.cssSelector(".alignnone.size-full.wp-image-399")).click();
You can use driver.switchTo().defaultContent();
to move out from frame.
iframe
have you switched into that frame before click on that image ?