我正在浏览网址:
http://serve.qa.vdopia.com/adserver/html5/inwapads/?sleepAfter=0;adFormat=banner;ak=e833a81e238ce8dc876a5f0a283953c2;version=1.0;cb=[timestamp];output=html.
我正在尝试点击xpath=//a/img[1]
所在的图片,但我无法点击它,但我能够成功找到它。到目前为止,我已尝试过这些选项,但它们都没有成功。任何帮助将不胜感激。
//#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);