这是我希望鼠标继续前进的元素。 <div id="div282" class="divAsset">
在鼠标悬停时,一些元素将可见,我想单击
<a class="tileDownloadButton button" title="Download" target="_blank" href="xxxxx"> Download </a>
如何将鼠标悬停在以下元素上,然后单击可见按钮?
答案 0 :(得分:0)
Python
asset = driver.find_element_by_id("div282")
action.move_to_element(asset).perform();
button = driver.find_element_by_xpath("//a[contains(text(),'Download')]");
button.click()
Java
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.id("div282"))).perform();
driver.findElement(By.xpath("//a[contains(text(),'Download')]")).click();
答案 1 :(得分:0)
您可以执行jquery将鼠标悬停在元素上。
python中的示例。
driver.execute_script("$('.classname').trigger('mouseover')") #selecting element based on classname.
Java示例:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("$('.classname').trigger('mouseover')");
这将使元素可见,然后您可以轻松单击元素。
查看其他jquery选择器here