如何单击SVG容器内的元素?

时间:2019-06-19 07:02:30

标签: java selenium selenium-webdriver

我想点击下面网址(http://wallethub.com/profile/test_insurance_company/)中的第五颗星。

在chrome版本(75),Java(12.0.1。)和硒(2.53.1)中使用了以下代码

WebElement svgObject = driver.findElement(By.xpath("/*[name()='svg']/*[name()='path']"));
Actions builder = new Actions(driver);
builder.click(svgObject).build().perform();

I tried changing with differnt types of xpath as below.But i could not do it.Please help me to find the solution.

//*[starts-with(@id,'reviews-section')]/svg:div[1]/svg:div[3]/svg:review-star/svg:div/svg:svg[5]/svg:g/svg:path


//*[starts-with(@id,'highcharts')]/svg:svg/svg:g[6]/svg:g[1]/svg:rect[2]



//*[@id="reviews-section"]/div[1]/div[3]/review-star/div/svg[5]/*[name()="g"]/*[name()="path"][starts-with(@d, "M6.37,32l3.972")]

//*[@id="chartdiv"]/div/div[1]/*[name()="svg"]/*[name()="g"][7]/*[name()="g"]/*[name()="g"][1]/*[name()="path"][starts-with(@d, "M371.75,174.28l")] 




//*[starts-with(@id,'reviews-section')]/svg:div[1]/svg:div[3]/svg:review-star/svg:div/svg:svg[5]/svg:g/svg:path


//*[starts-with(@id,'highcharts')]/svg:svg/svg:g[6]/svg:g[1]/svg:rect[2]



//*[@id="reviews-section"]/div[1]/div[3]/review-star/div/svg[5]/*[name()="g"]/*[name()="path"][starts-with(@d, "M6.37,32l3.972")]

//*[@id="chartdiv"]/div/div[1]/*[name()="svg"]/*[name()="g"][7]/*[name()="g"]/*[name()="g"][1]/*[name()="path"][starts-with(@d, "M371.75,174.28l")]

WebElement svgObject = driver.findElement(By.xpath("/*[name()='svg']/*[name()='path']"));
Actions builder = new Actions(driver);
builder.click(svgObject).build().perform();

0 个答案:

没有答案