How do I automate pie and bar charts using selenium?

I just want to automate a diagram action in Selenium? Web Driver / Java (Kendo Ui)

how can i click on the segments of the chart

My graph is exactly the same link in the below link

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

+3


source to share


3 answers


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

Let's assume your url is:

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



If you need to find the text of an element in a pie chart, you can use the below code:

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

+2


source


I need to automate a lot of pages that make heavy use of different Kendo controls. I work at Telerik and we use Test Studio for our automation. However, you can apply our approach. I usually read the javascript API documentation for the control I want to automate. There are many methods that can be performed for each one.

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

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

      



You can create extension methods around controls for these specific methods.

If you have any questions, do not hesitate to contact me!

+1


source


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

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();
                            }
                    }

      

+1


source







All Articles