Click Specific Item In Image Map Using Selenium 3 Webdriver

前端 未结 1 1404
礼貌的吻别
礼貌的吻别 2021-01-17 00:54

I am using Selenium 3.3.1 and the Java Webdriver bindings, and need to click a specific item in an image map on a page. Here is the HTML for the image map

&l         


        
1条回答
  •  囚心锁ツ
    2021-01-17 01:21

    Answering my own question because the answer came from a suggestion in the comments. Using a javascript executor was the answer. Something like:

    WebElement banner = driver.findElement(By.cssSelector("map"));
    WebElement area = banner.findElement(By.id("reports"));
    
    JavascriptExecutor executor = (JavascriptExecutor)driver;
    executor.executeScript("arguments[0].click();", area);
    

    0 讨论(0)
提交回复
热议问题