Get data from TOOLTIPS in highcharts

1,597 views
Skip to first unread message

ama...@bufetedemarketing.com

unread,
May 12, 2017, 3:08:04 AM5/12/17
to Selenium Users
Hi guys! I have the following highcharts point with tooltip:



I've written the following with Eclipse and Selenium Webdriver, but it doesn't appear the data inside the tooltip, why? 


            List <WebElement> shapes2 = driver.findElements((By.className("highcharts-tooltip"))); //this doesn't show any data from tooltip
            System.out.println();
            System.out.println("*** Array size to control 2: " +shapes2.size()); 
            
            java.util.Iterator<WebElement> k = shapes2.iterator();
            while(k.hasNext()) {
                WebElement row2 = k.next();
                System.out.println(row2.getText() + " ** ");}


Thanks so much for your help!!!!

ama...@bufetedemarketing.com

unread,
May 12, 2017, 3:19:36 AM5/12/17
to Selenium Users
I show how the visibility changes between HIDDEN and VISIBLE when the mouse is on the point of the graphic:



Could I use this "field" VISIBILITY to can get the data??? Because using classname: highcharts-tooltip, doesn't show any data.

Thanks so much!!!!

ama...@bufetedemarketing.com

unread,
May 12, 2017, 7:27:48 AM5/12/17
to Selenium Users
I've found a few solutions in Google, but I'm not able to get any data... any ideas?? Thanksss!!!


/*1. selenium.mouseOver("//*[@id='mainnavigation']/div[1]/ul/li[1]/a");
String myTitle = selenium.getAttribute("//*[@id='mainnavigation']/div[1]/ul/li[1]/a@title"); */
           
          
           
/*2. OverviewTip = Globals.driver.findElement(By.xpath(Home_Page.divGroupchatTooltip)).getText();*/
           
           
/*3. String tooltip=wd.findElement(By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[1]")).getAttribute("title"); 
System.out.println(tooltip); */
           
           
/*4. function isHidden(el) {
    var style = driver.getComputedStyle(el);
    return (style.display === 'none')
}*/

           
/*5. if(getComputedStyle(elm).visibility === 'hidden') { return false; }*/
/*6. const style = getComputedStyle(driver);
var style = driver.getComputedStyle(el);*/
           
           
/*7.  var element = driver.getElementById("element");
if(element.style.visibility == "hidden"){System.out.println();}*/

Xiang Dong

unread,
May 12, 2017, 9:21:57 AM5/12/17
to seleniu...@googlegroups.com


Highcharts parts is not the "title" attribute, it is under the <text> element. you can use css to locate it and get the content. Some of move action are not works on the Highcharts, you can use click to trigger the tooltip displayed.

--david


From: seleniu...@googlegroups.com <seleniu...@googlegroups.com> on behalf of ama...@bufetedemarketing.com <ama...@bufetedemarketing.com>
Sent: Friday, May 12, 2017 7:27 PM
To: Selenium Users
Subject: [selenium-users] Re: Get data from TOOLTIPS in highcharts
 
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/538b7810-69a6-41ec-a5a9-4d2cefc4952d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xiang Dong

unread,
May 12, 2017, 9:40:33 AM5/12/17
to seleniu...@googlegroups.com

The default div with tooltip class does not contains data, you should click a dot in the chart and the tooltip will displayed and the element has the text. then, you can get it back. 


BTW: the last email from me said the tooltip in the <text> element is not correct, for bubble chart, it is under a normal div>span>table. 


--david




Sent: Friday, May 12, 2017 3:08 PM
To: Selenium Users
Subject: [selenium-users] Get data from TOOLTIPS in highcharts
 
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

ama...@bufetedemarketing.com

unread,
May 16, 2017, 3:22:53 AM5/16/17
to Selenium Users
Hi David!

1. If I write the css of one point of the highcharts, I can't either get the data... 
                               List <WebElement> shapes = driver.findElements((By.cssSelector(".//*[@id='highcharts-4']/div[1]/span")));

2. I don't know how to put "<div>" to get data in a command... If I have this command:
                     List <WebElement> shapes = driver.findElements((By.className("highcharts-container")));
    How could I re-write to use "<div>???
                              

3. I tried writing the xpath too, but it didn't work...  
                             List <WebElement> shapes = driver.findElements((By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[1]")));


Could anyone give me another solution, please?

I'm turning crazy... :(

Thanks so much!!!


El viernes, 12 de mayo de 2017, 15:40:33 (UTC+2), David Dong escribió:

The default div with tooltip class does not contains data, you should click a dot in the chart and the tooltip will displayed and the element has the text. then, you can get it back. 


BTW: the last email from me said the tooltip in the <text> element is not correct, for bubble chart, it is under a normal div>span>table. 


--david




From: seleniu...@googlegroups.com <seleniu...@googlegroups.com> on behalf of ama...@bufetedemarketing.com <ama...@bufetedemarketing.com>
Sent: Friday, May 12, 2017 3:08 PM
To: Selenium Users
Subject: [selenium-users] Get data from TOOLTIPS in highcharts
 
Hi guys! I have the following highcharts point with tooltip:



I've written the following with Eclipse and Selenium Webdriver, but it doesn't appear the data inside the tooltip, why? 


            List <WebElement> shapes2 = driver.findElements((By.className("highcharts-tooltip"))); //this doesn't show any data from tooltip
            System.out.println();
            System.out.println("*** Array size to control 2: " +shapes2.size()); 
            
            java.util.Iterator<WebElement> k = shapes2.iterator();
            while(k.hasNext()) {
                WebElement row2 = k.next();
                System.out.println(row2.getText() + " ** ");}


Thanks so much for your help!!!!

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleni...@googlegroups.com.

ama...@bufetedemarketing.com

unread,
May 16, 2017, 3:39:30 AM5/16/17
to Selenium Users
Hi David!

1. If I write the css of one point of the highcharts, I can't either get the data... 
                               List <WebElement> shapes = driver.findElements((By.cssSelector(".//*[@id='highcharts-4']/div[1]/span")));


2. I don't know how to put "<div>" to get data in a command... If I have this command:
                     List <WebElement> shapes = driver.findElements((By.className("highcharts-container")));
    ***I've re-written the following with "<div>" but It doesn't work:
                                  List <WebElement> shapes2 = driver.findElements((By.cssSelector("div.highcharts-tooltip"))); 

ama...@bufetedemarketing.com

unread,
May 16, 2017, 6:18:44 AM5/16/17
to Selenium Users
I've been working with this again and I've tried the following failes instructions, I don't get data... :(

 System.out.println(driver.findElement(By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[1]"))); 

 System.out.println(driver.findElement(By.id("highcharts-4")).getAttribute("title"));

 System.out.println(driver.findElement(By.id("highcharts-4")).getAttribute("path"));

 System.out.println(driver.findElement(By.id("highcharts-4")).getAttribute("svg"));
  
 System.out.println(driver.findElement(By.id("highcharts-4")).getText());

System.out.println(driver.findElement(By.id("highcharts-4")).getCssValue("div.highcharts-tooltip"));

 System.out.println(driver.findElement(By.id("highcharts-4")).getCssValue("div.highcharts-tooltip"));
 System.out.println(driver.findElement(By.className("div.highcharts-tooltip")).getText());

System.out.println(driver.findElement(By.cssSelector("div.highcharts-tooltip")).getText());
System.out.println(driver.findElement(By.className("highcharts-series")).getText());

 System.out.println(driver.findElement(By.className("highcharts-series-group")).getText());

 System.out.println(driver.findElement(By.className("highcharts-tracker")).getText());
System.out.println(driver.findElement(By.className("highcharts-tooltip")).getText());

System.out.println(driver.findElement(By.cssSelector("div.highcharts-tracker")).getText());
System.out.println(driver.findElement(By.cssSelector("div.highcharts-series-group")).getText());
System.out.println(driver.findElement(By.cssSelector("div.highcharts-4.highcharts-container")).getText());
 System.out.println(driver.findElement(By.className("highcharts-legend-item")).getText());
System.out.println(driver.findElement(By.id("highcharts-4")).getAttribute("rect"));
System.out.println(driver.findElement(By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[2]")).getText()); 
System.out.println(driver.findElement(By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[3]")));
System.out.println(driver.findElement(By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[7]")));
System.out.println(driver.findElement(By.xpath(".//*[@id='highcharts-4']/div[1]/span"))); 
System.out.println(driver.findElement(By.xpath(".//*[@id='highcharts-4']/svg/rect")));
System.out.println(driver.findElement(By.className("highcharts-series")).getAttribute("rect"));



Any ideas??? Thanks so much guys!!!

ama...@bufetedemarketing.com

unread,
May 16, 2017, 7:04:59 AM5/16/17
to Selenium Users
I've found the following useful web page to verify tooltips from Selenium Webdriver: http://www.seleniumeasy.com/selenium-tutorials/how-to-verify-tooltip-text-with-selenium-webdriver-using-java

But I don't know to identify my "boxElement" where my tooltip is... I've tried with "highcharts-4", but it doesn't work.

How could I re-write the following code with my case? (I attached some pictures showing the classes last week) If you could help me... I'll be vert grateful...

Actions action = new Actions(driver); WebElement element = driver.findElement(By.id("boxElement")); actions.moveToElement(element).build().perform();


Thanks so much guys...



El viernes, 12 de mayo de 2017, 9:08:04 (UTC+2), ama...@bufetedemarketing.com escribió:

ama...@bufetedemarketing.com

unread,
May 16, 2017, 7:17:19 AM5/16/17
to Selenium Users


El martes, 16 de mayo de 2017, 13:04:59 (UTC+2), ama...@bufetedemarketing.com escribió:
I've found the following useful web page to verify tooltips from Selenium Webdriver: http://www.seleniumeasy.com/selenium-tutorials/how-to-verify-tooltip-text-with-selenium-webdriver-using-java

But I don't know to identify my "boxElement" where my tooltip is... I've tried with "highcharts-4", but it doesn't work.

How could I re-write the following code with my case? (I attached some pictures showing the classes last week) If you could help me... I'll be vert grateful...

Actions action = new Actions(driver); WebElement element = driver.findElement(By.id("boxElement")); actions.moveToElement(element).build().perform();

 
In my case, I've tried with these information:

                // Text box field, where we mouse hover
WebElement element = driver.findElement(By.id("highcharts-4"));

// Use action class to mouse hover on Text box field
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
WebElement toolTipElement = driver.findElement(By.cssSelector(".highcharts-tooltip"));

// To get the tool tip text and assert
String toolTipText = toolTipElement.getText();
Assert.assertEquals("Prueba de verificación de tooltip.", toolTipText); 

Could anyone give me an advise?

ama...@bufetedemarketing.com

unread,
May 16, 2017, 7:40:19 AM5/16/17
to Selenium Users
I've written the following:

                WebElement element = driver.findElement(By.id("highcharts-4"));

// Use action class to mouse hover on Text box field
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
WebElement toolTipElement = driver.findElement(By.cssSelector(".highcharts-tooltip"));

// To get the tool tip text and assert
String toolTipText = toolTipElement.getText();
Assert.assertEquals("Prueba de verificación de tooltip.", toolTipText);

But it returns: "error validation "[]"", so, it doesn't work... why??

Thanks so much...!!!!


El viernes, 12 de mayo de 2017, 9:08:04 (UTC+2), ama...@bufetedemarketing.com escribió:

Xiang Dong

unread,
May 16, 2017, 8:34:54 AM5/16/17
to Selenium Users
What highcharts type are you tested? Line, Column or Pie? Could you click the element instead of move to? Looks id=highchart-4 is not a dot, pie or column on the chart, it is the chart itself, please make sure you move to the expected element. Some of moveto action may not works on highchart to trigger tooltip displayed, instead of moveto, you can click the expected element on the chart. Please make sure you see the tooltip after the moveto or click action done from the web page.

David
Sent: Tuesday, May 16, 2017 7:40:19 PM
To: Selenium Users
Subject: [selenium-users] Re: Get data from TOOLTIPS in highcharts
 
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

ama...@bufetedemarketing.com

unread,
May 17, 2017, 3:00:09 AM5/17/17
to Selenium Users
Hi David, 

I have a dot highchart, I show you in the last image:


When I put the mouse on the dot, the tooltip appears. the xpath of this kind of dots is: .//*[@id='highcharts-4']/svg/g[5]/g[2]/path[1]
but I try to put this label and nothing happen. 

I have the following code:

                // Text box field, where we mouse hover
WebElement element = driver.findElement(By.id("highcharts-4"));

// Use action class to mouse hover on Text box field
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
//testing WebElement toolTipElement = driver.findElement(By.cssSelector("highcharts-tooltip"));
WebElement toolTipElement = driver.findElement(By.xpath(".//*[@id='highcharts-4']/div[1]/span"));

// To get the tool tip text and assert
String toolTipText = toolTipElement.getText();
System.out.println(toolTipText);


Why doesn't it work?

Thanks so much!!!!!!!!!!
To post to this group, send email to seleni...@googlegroups.com.

ama...@bufetedemarketing.com

unread,
May 17, 2017, 3:26:04 AM5/17/17
to Selenium Users
Well... I've modify the following code, but still, it doesn't work:

                // Dot in the highchart, where we mouse hover
WebElement element = driver.findElement(By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[1]")); 

// Use action class to mouse hover on dot highchart
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
WebElement toolTipElement = driver.findElement(By.className("highcharts-tooltip"));

// To get the tool tip text 
String toolTipText = toolTipElement.getText();
System.out.println(toolTipText);



El viernes, 12 de mayo de 2017, 9:08:04 (UTC+2), ama...@bufetedemarketing.com escribió:

ama...@bufetedemarketing.com

unread,
May 17, 2017, 3:29:22 AM5/17/17
to Selenium Users
El miércoles, 17 de mayo de 2017, 9:26:04 (UTC+2), ama...@bufetedemarketing.com escribió:

Well... I've modify the following code, but still, it doesn't work (Selenium doesn't identify the xpath I tell him...I don't know why. This is the xpath of the dot)

ama...@bufetedemarketing.com

unread,
May 17, 2017, 3:51:36 AM5/17/17
to Selenium Users
I show you the screenshots of my dot highcharts, this way, maybe, you could say to me what I'm doing wrong (I hope so :( )


What is wrong with my code?: 


                // Dot in the highchart, where we mouse hover
WebElement element = driver.findElement(By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[1]"));   
 //this line cause an error in Selenium, stops the execution, it doesn't find the element that I want (the dot)

// Use action class to mouse hover on dot highchart
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
WebElement toolTipElement = driver.findElement(By.className("highcharts-tooltip"));

// To get the tool tip text 
String toolTipText = toolTipElement.getText();
System.out.println(toolTipText);


Thanks soooooooo much guys!!

ama...@bufetedemarketing.com

unread,
May 17, 2017, 4:10:57 AM5/17/17
to Selenium Users
I've tried too with the following and it doesn't cause errors, but it doesn't show any data. So... I'm turning crazy :(


WebElement element = driver.findElement(By.xpath(".//*[@id='highcharts-4']/div[1]/span"));   

// Use action class to mouse hover on dot highchart
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
WebElement toolTipElement = driver.findElement(By.className("highcharts-tooltip"));

// To get the tool tip text 
String toolTipText = toolTipElement.getText();
System.out.println(toolTipText);


Thanks guys.... I need you :(

ama...@bufetedemarketing.com

unread,
May 17, 2017, 5:40:46 AM5/17/17
to Selenium Users
I've tried to extract information of this way:

WebElement element = driver.findElement(By.xpath(".//*[@id='highcharts-4']/div[1]/span"));   

// Use action class to mouse hover on dot highchart
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
WebElement toolTipElement = driver.findElement(By.className("highcharts-tooltip"));

System.out.println(toolTipElement.getAttribute("span")+" span");
System.out.println(toolTipElement.getAttribute("b")+" b");
System.out.println(toolTipElement.getAttribute("path")+" path");
System.out.println(toolTipElement.getAttribute("svg")+" svg");
System.out.println(toolTipElement.getAttribute("title")+" title");
System.out.println(toolTipElement.getAttribute("target")+" target");
System.out.println(toolTipElement.getAttribute("e")+" e");
System.out.println(toolTipElement.getAttribute("parentNode")+" parentNode");
System.out.println(toolTipElement.getAttribute("g")+" toolTipElement g");

And I get the following:
g tagName 
   getText 
-2087190918 hashCode 
false isDisplayed             
true isEnabled 
false isSelected 
[[FirefoxDriver: firefox on ANY (ae23faae-4dfb-4846-8586-9ab45e513c56)] -> class name: highcharts-tooltip] toString 
(181, 375) getLocation 
class org.openqa.selenium.remote.RemoteWebElement getClass
org.openqa.selenium.Rectangle@af82 getRect
(21, 21) getSize 

I don't know why it's showed that is not displayed, because it is.
I think that from here the most important info is: class org.openqa.selenium.remote.RemoteWebElement getClass, 
Am I right? could I change any thing with that "new name class"??

Thanks... I'll keep studying new ways...

ama...@bufetedemarketing.com

unread,
May 17, 2017, 6:42:48 AM5/17/17
to Selenium Users
I think that the correct code would be the following, but however, it doesn't work for me and I don't know why Selenium doesn't find my xpath dot:


        //dot of the highchart where I put my mouse to see the tooltip. Selenium Webdriver doesn't find it and it causes an error, it stops the execution here
WebElement element = driver.findElement(By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[5]"));  //dot's xpath
// Use action class to mouse hover on the dot
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
WebElement toolTipElement = driver.findElement(By.xpath(".//*[@id='highcharts-4']/div[1]/span"));      //xpath of the shown tooltip

// To get the tool tip text 
String toolTipText = toolTipElement.getText();   


Thanks so much... :(

ama...@bufetedemarketing.com

unread,
May 17, 2017, 7:23:44 AM5/17/17
to Selenium Users
I think that the correct code would be the following, but however, it doesn't work for me and I don't know why Selenium doesn't find my xpath dot:


        //dot of the highchart where I put my mouse to see the tooltip. Selenium Webdriver doesn't find it and it causes an error, it stops the execution here
WebElement element = driver.findElement(By.xpath(".//*[@id='highcharts-4']/svg/g[5]/g[2]/path[5]"));  //dot's xpath
// Use action class to mouse hover on the dot
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
WebElement toolTipElement = driver.findElement(By.xpath(".//*[@id='highcharts-4']/div[1]/span"));      //xpath of the shown tooltip

// To get the tool tip text 
String toolTipText = toolTipElement.getText();   


Thanks so much... :(


I've seen the following code that I don't know if it is something that could help me, so I ask you if it's something important to pay attention:
 

 

Thankssssssssssssss

Xiang Dong

unread,
May 17, 2017, 8:59:07 AM5/17/17
to seleniu...@googlegroups.com

First, this xpath towards an sub-element under the <svg>, xpath does not works well for this case. the alternative way is use the css to locate the dot. 


second, moveto action may not trigger the tooltip displayed, an alternative way is use click action


third, the tooltip element is a span, an standard html element, you can use xpath or others to locate the element.


your code still try use xpath to locate dot element and use the moveto action, it is the reason why you can't get the expect result.


--david




Sent: Wednesday, May 17, 2017 7:23 PM

To: Selenium Users
Subject: [selenium-users] Re: Get data from TOOLTIPS in highcharts
 
I think that the correct code would be the following, but however, it doesn't work for me and I don't know why Selenium doesn't find my xpath dot:
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

ama...@bufetedemarketing.com

unread,
May 18, 2017, 3:04:50 AM5/18/17
to Selenium Users
Hi David! Thanks so much for your answer!

You said:
          "third, the tooltip element is a span, an standard html element, you can use xpath or others to locate the element." (what are "others?")

But you said too: 
            "First, this xpath towards an sub-element under the <svg>, xpath does not works well for this case." 

So... I understand that I have to use another option (instead of xpath) to access my dot. Right? I'll try with css although I just did it before... I'll keep testing...

Thanks so much... I'll continue updating... 

To post to this group, send email to seleni...@googlegroups.com.

Xiang Dong

unread,
May 18, 2017, 4:08:10 AM5/18/17
to Selenium Users
Others just mean any locators, by id or name or others. Please let me know your result
Sent: Thursday, May 18, 2017 3:04:50 PM
To: Selenium Users
Subject: Re: [selenium-users] Re: Get data from TOOLTIPS in highcharts
 

Xiang Dong

unread,
May 18, 2017, 4:11:54 AM5/18/17
to Selenium Users
Tooltip is a standard HTML element, you can use any web driver support locator. Dot element is a svg child element, xpath not works well, please use CSS to do it. The other, please click the dot element instead of moveto

David
Sent: Thursday, May 18, 2017 3:04:50 PM
To: Selenium Users
Subject: Re: [selenium-users] Re: Get data from TOOLTIPS in highcharts
 

ama...@bufetedemarketing.com

unread,
May 18, 2017, 4:26:00 AM5/18/17
to Selenium Users
HI David, thanks so much for your patience.

I don't know how I could locate the dots with others locators because I don't see any information in my code, I show you:


I don't have "id" or "css", or "name" to use... 

I show you the data in <span> tags:


Thanks so much for your time... :(

ama...@bufetedemarketing.com

unread,
May 18, 2017, 5:01:48 AM5/18/17
to Selenium Users
I've tried this, but it doesn't work again... I don't know how to test it... 

WebElement element = driver.findElement(By.cssSelector("div[id^='highcharts-4'] span.highcharts-tooltip")).getText();

Thanks a lot!!!! 

ama...@bufetedemarketing.com

unread,
May 18, 2017, 5:05:07 AM5/18/17
to Selenium Users
I've tried this, but it doesn't work again... 

WebElement element = driver.findElement(By.cssSelector("div[id^='highcharts-4'] span.highcharts-tooltip"));

I don't know how to locate it...  

ama...@bufetedemarketing.com

unread,
May 18, 2017, 6:24:56 AM5/18/17
to Selenium Users
I've tried with: System.out.println(String p1 = driver.findElement(By.cssSelector("#highcharts-4 svg")).getText()+" getText()");

And I get the % of the axis: "Created with Highcharts 3.0.24,68 %0,00 %2,50 %5,00 %7,50 %10,00 % getText()"

But I don't get the data in the tooltip yet...

I'll keep studying... thankssssss

Monika Singhal

unread,
May 18, 2017, 7:34:17 AM5/18/17
to Selenium Users
Hi,

Please use this xpath for locating the element:

.//*[@id='highcharts-4']/*[name()='svg']/*[name()='g'][5]/*[name()='g'][2]/*[name()='path'][5]

The above xpath should work for you.

Thanks& Regards,
Monika

Xiang Dong

unread,
May 18, 2017, 7:45:04 AM5/18/17
to Selenium Users
CSS is something similar like xpath, it represent the position of the element, you could use chrome to get it. Pick up the element from the DOM, click right key, choose copy selector, but you must make sure no dynamic id in it, highchart may has the dynamic Id on the top div. it is better you copy your full HTML and send to me. The span can use the same way to get xpath or CSS selector. But either way should be ok for the span element.
Sent: Thursday, May 18, 2017 4:26:00 PM

Xiang Dong

unread,
May 18, 2017, 7:46:37 AM5/18/17
to Selenium Users
This xpath should be ok. Only name() works in the xpath for looking for an element under svg
From: seleniu...@googlegroups.com <seleniu...@googlegroups.com> on behalf of Monika Singhal <singhal...@gmail.com>
Sent: Thursday, May 18, 2017 7:34:17 PM

ama...@bufetedemarketing.com

unread,
May 18, 2017, 7:46:39 AM5/18/17
to Selenium Users
I've found the following web page with info: http://stackoverflow.com/questions/41829000/selenium-webdriver-java-how-to-click-on-elements-within-an-svg-using-xpath

I'veI've tried with this command: 

//div[@class="highcharts-4"][contains(.,"AXA")]/div//div[@class="highcharts-tooltip"]/*[name(‌​)="svg"]//*[name()="‌​g"]/*[name()="path" and @fill="#2f7ed8"]

 but it doesn't work, it causes an syntaxis error in eclipse, I don't know why...

Thanks for your patience...

Xiang Dong

unread,
May 18, 2017, 7:48:50 AM5/18/17
to Selenium Users
Java code? I guess it is due to ", change it to '.

David
Sent: Thursday, May 18, 2017 7:46:39 PM

ama...@bufetedemarketing.com

unread,
May 18, 2017, 7:51:07 AM5/18/17
to Selenium Users
Ok guys, I'll test it and I'll tell you...

Thanks so much for your time... I'll keep you informed!! :)

ama...@bufetedemarketing.com

unread,
May 18, 2017, 8:00:03 AM5/18/17
to Selenium Users

It doesn’t work :(

 

I write:

System.out.println(driver.findElement(By.xpath(".//*[@id='highcharts-4']/*[name()='svg']/*[name()='g'][5]/*[name()='g'][2]/*[name()='path'][1]")).getText());

 

I’ll show you the result: it returns empty.



 

Why?? Thanks!!!!!!

Monika Singhal

unread,
May 18, 2017, 8:02:49 AM5/18/17
to seleniu...@googlegroups.com
Can you share the exact HTML. I will verify it on my end 

You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/wWK2hVviZno/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd5f936a-74fe-451c-b392-f10ff1d099db%40googlegroups.com.

Xiang Dong

unread,
May 18, 2017, 8:03:48 AM5/18/17
to Selenium Users
Below xpath is the dot element, you need click it to make the tooltip element, then has the text from tooltip element:

Step are:
1. Find the dot element with below xpath
2. Click the dot element
3. Find the tooltip element
4. Get the text


Sent: Thursday, May 18, 2017 8:00:03 PM

ama...@bufetedemarketing.com

unread,
May 19, 2017, 3:15:25 AM5/19/17
to Selenium Users
I attach you guys a piece of HTML of the part of Highcharts with my "forbidden" code impossible to get...

I'm going to test with CLICK action as David tell me, and I'll keep writing results here...

Thanks so much for your help guys....
html highcharts.txt

ama...@bufetedemarketing.com

unread,
May 19, 2017, 3:33:27 AM5/19/17
to Selenium Users

Done! I click on the element and I got it!!!!!!!!!!

 

Thanks a lot guys!!!!!!!!!!!! 


Solved at least!!!!!!!!!!!!!!!!!!!!! :)

Xiang Dong

unread,
May 19, 2017, 3:59:39 AM5/19/17
to seleniu...@googlegroups.com

Great. It is due to some special in Highcharts test. Not a good test scenario, but congratulation you get it work.


--david




Sent: Friday, May 19, 2017 3:33 PM

ama...@bufetedemarketing.com

unread,
May 19, 2017, 4:24:39 AM5/19/17
to Selenium Users
All thanks to you guys. :)

Now...

Like you know… I have the xpath Monika told me: .//*[@id='highcharts-4']/*[name()='svg']/*[name()='g'][5]/*[name()='g'][2]/*[name()='path'][3]

To navigate between dots (from path[1] to path[10]).

 

If I have the xpath of the tooltip as: .//*[@id='highcharts-4']/div[1]/span

 

How could I get the tooltip for the followings dots from [1] to [10] ?

 

I’ve tried to get data from tooltip of element number 4:      

        

-          .//*[@id='highcharts-4']/div[4]/span   But it isn’t found

-          .//*[@id='highcharts-4']/*[name()='div'][4]/*[name()='span']   It isn’t either found

What am I doing wrong?

 

Thanks so much!!!

ama...@bufetedemarketing.com

unread,
May 19, 2017, 4:36:45 AM5/19/17
to Selenium Users
The xpath of the tooltip is:  .//*[@id='highcharts-4']/div[1]/span

I can’t be able to get data of different dots, I only get data from the first dot, If I want to get data after from different dots in the same execution I get the same data for all dots

The result of the execution is:

TEST DOT PATH 1
IMQ
Crecimiento 0,81 %  (1,86 mill.)
Diferencia con mercado -3,86 p.p.
TEST DOT PATH 3
IMQ
Crecimiento 0,81 %  (1,86 mill.)
Diferencia con mercado -3,86 p.p.

How could I get data for different dots??

Thanks a lot.... this is a never-ending-story :(

Monika

For more options, visit <a href="https://groups.google.com/d/optout" rel="n

Xiang Dong

unread,
May 19, 2017, 4:40:47 AM5/19/17
to seleniu...@googlegroups.com

there is only one tooltip element in the DOM. You can click different dot to make the text in the tooltip changed.  the XPATH you used to locate dot element should be changed as well. 

.//*[@id='highcharts-4']/*[name()='svg']/*[name()='g'][5]/*[name()='g'][2]/*[name()='path'][3]

The red number can be changed to different dot element.


Sent: Friday, May 19, 2017 4:36 PM

ama...@bufetedemarketing.com

unread,
May 19, 2017, 4:44:41 AM5/19/17
to Selenium Users
I show you my code...this returns the same info for both dots.


                System.out.println("TEST PUNTO PATH 1");
WebElement element = driver.findElement(By.xpath(".//*[@id='highcharts-4']/*[name()='svg']/*[name()='g'][5]/*[name()='g'][2]/*[name()='path'][1]"));
// Use action class to mouse hover on Text box field
Actions action = new Actions(driver);
action.click(element).build().perform();
//tooltip class
WebElement toolTipElement = driver.findElement(By.xpath(".//*[@id='highcharts-4']/div[1]/span")); //xpath tooltip shown
System.out.println(toolTipElement.getText());
////////////////////////////////////////////
System.out.println("TEST PUNTO PATH 3");
WebElement element1 = driver.findElement(By.xpath(".//*[@id='highcharts-4']/*[name()='svg']/*[name()='g'][5]/*[name()='g'][2]/*[name()='path'][3]"));
// Use action class to mouse hover on Text box field
Actions action1 = new Actions(driver);
action1.click(element1).build().perform();
//tooltip class
WebElement toolTipElement1 = driver.findElement(By.xpath(".//*[@id='highcharts-4']/div[1]/span")); //xpath tooltip shown
System.out.println(toolTipElement1.getText());
Monika

ama...@bufetedemarketing.com

unread,
May 19, 2017, 5:15:49 AM5/19/17
to Selenium Users
I have seen in the execution that the mouse moves on different dot but the tooltip doesn't change, so, I get the same information in both dots.
I'll try to click in other area between dots.... I'll keep you informed...

Thanks...

ama...@bufetedemarketing.com

unread,
May 19, 2017, 5:44:12 AM5/19/17
to Selenium Users
Done, I put some sleep time and click to another dot of the web page and it works! :D

 

Sorry for the inconveniences!!!

 

Thanks so much!!!

Monika

</di
Reply all
Reply to author
Forward
0 new messages