点击使用WebDriver的链接上的事件显示“;javascript:void(0)"状态栏上
Click event on link using WebDriver shows "javascript:void(0)" on status bar
我正试图点击鼠标悬停事件生成的下拉列表中的第一个链接。
尝试了很多选项,但没有成功,只在状态栏上看到"javascript:void(0)"。到目前为止,设法在鼠标悬停时显示下拉列表。唯一的问题是点击第一个链接。
<a title="Insert" href="#">
<span>Insert</span>
</a>
<ul>
<li class="standardContent">
<a id="id193" title="Modules & Topics from a Library" href="#"> Modules & Topics from a Library </a>
</li>
<li class="customModule">
在这里我想点击元素"模块和主题从一个图书馆"。由于id是动态更改的。所以不能用来点击。
Actions act = new Actions(driver);
WebElement iconhover = driver.findElement(By.className("insertItems"));
act.moveToElement(iconhover).click().build().perform();
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement mod = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@class='standardContent']")));
mod.click();
下一次尝试
Actions act = new Actions(driver);
WebElement iconhover = driver.findElement(By.className("insertItems"));
act.moveToElement(iconhover).click().build().perform();
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement mod = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@class='standardContent']")));
WebElement a = driver.findElement(By.xpath("//*[@class='insertItems']/ul"));
List <WebElement> ancartag= a.findElements(By.tagName("a"));
for (int i=0; i<ancartag.size();i++){
System.out.println(ancartag.get(0));
ancartag.get(0).click();
}
尝试下面的片段:
WebElement element = driver.findElement(By.tagName("Modules & Topics from a Library"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
相关文章:
- 如何使用JavaScriptExecutor来获取出现在浏览器上的文本's状态栏
- Rhomobile:正在更新通知/状态栏
- 浏览器状态栏:隐藏对特定网站的请求地址
- 当鼠标悬停在链接上时,从 href URL 中隐藏状态栏值
- 使用Phonegap Build隐藏Android中的状态栏
- 如何将 phonegap 2.9.0 更新到 3.0 或在 phonegap 应用程序中隐藏状态栏
- 在状态栏中隐藏网址
- 状态栏中的推送通知 安卓科尔多瓦.
- 如何删除配置文件中的状态栏
- 创建一个可以在javascript中不断移动的状态栏
- 在IE8中隐藏地址栏和状态栏
- 带有状态栏的表单
- location.href将鼠标悬停在链接上时,使目标显示在状态栏中
- 点击状态栏不会滚动到应用程序的顶部(Trigger.io)
- 点击使用WebDriver的链接上的事件显示“;javascript:void(0)"状态栏上
- web应用程序中的状态栏通知
- jQuery-在呼叫状态栏中检测iPhone
- Phonegap状态栏通知,Android,iOS
- 状态栏中的屏蔽链接仅在第一次单击之前有效
- 在Firefox中隐藏状态栏