I am browsing the url:
http://serve.qa.vdopia.com/adserver/html5/inwapads/?sleepAfter=0;adFormat=banner;ak=e833a81e238ce8dc876a5f0a283953c2;version=1.0;cb=[timestamp];output=html.
I am trying to click the image located by xpath=//a/img[1]
, but I can't click it though I am able to find it successfully. I have tried these options so far, but none of them are successful yet. Any help will be appreciated.
//#1.
WebElement bannerImage = driver.findElement(By.xpath("//a/img[1]"));
bannerImage.click();
//#2.
WebElement bannerImage = driver.findElement(By.xpath("//a/img[1]"));
TouchActions flick = new TouchActions(driver).flick(bannerImage, -100, 0, 0);
flick.perform();
//#3.
String xpath = "//a/img[1]";
String js = "var targetElement = document.evaluate(\""+xpath+"\",document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;"
+"var evt = document.createEvent('UIEvent');"
+"evt.initUIEvent('touchstart', true, true);"
+"targetElement.dispatchEvent(evt);";
((JavascriptExecutor)driver).executeScript(js);