admin管理员组

文章数量:1302270

I just want to automate the chart action in Selenium? Web-driver/Java (Kendo Ui)

how can i click on the chart segments??

My graph is exactly same link in the below link

I just want to automate the chart action in Selenium? Web-driver/Java (Kendo Ui)

how can i click on the chart segments??

My graph is exactly same link in the below link

http://demos.telerik./kendo-ui/pie-charts/index

Share Improve this question asked May 5, 2015 at 10:31 Shanmuga RajShanmuga Raj 1251 gold badge2 silver badges16 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

ya i got the solution.... this is the code to drill down in chart

WebElement svg = gd.findElement(By.cssSelector("svg"));
List<WebElement> outertext = svg.findElements(By.cssSelector("text"));

                for(WebElement texts : outertext)
                    {
                        String textcollection = texts.getText();
                        if(textcollection.equals("xxxxxx"))
                            {
                                texts.click();
                            }
                    }

Finding xpath of the elements inside the svg tag is bit different than finding xpath of other elements.

Suppose your URL is:

https://developers.google./chart/interactive/docs/gallery/piechart

If you have to find the text of the element in the pie-chart then you can use the code mentioned below:

driver.findElement(By.xpath(" //[@id='piechart']/div/div[1]/div/[name()='svg']/[name()='g'][4]/[name()='text']")).getText();

I have to automate a lot of pages that heavily use different controls of Kendo. I'm working at Telerik, and we are using Test Studio for our automation. However, you can apply our approach. I usually read the javascript API documentation for the control that I want to automate. There are tons of methods that can be executed for every one of them.

Example: http://docs.telerik./kendo-ui/api/javascript/kendo You just need to find the appropriate method for your case and execute it the javascript via Web driver:

WebDriver driver = new AnyDriverYouWant();
if (driver instanceof JavascriptExecutor) {
    ((JavascriptExecutor)driver).executeScript("yourScript();");
}

You can create extensions methods around the controls for these particular methods.

If you have questions, don't hesitate to contact me!

本文标签: javascriptHow to automate pie charts and bar graphs using seleniumStack Overflow