Your 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")).();

You can use driver.switchTo().defaultContent(); to move out from frame.



Source link https://sqa.stackexchange.com/questions/31761/-to-click-image-in---

LEAVE A REPLY

Please enter your comment!
Please enter your name here