我们如何找到值ttl ="系列:客户数量,类别:东南和价值:使用硒从HTML中获得10,000

时间:2017-05-15 08:02:30

标签: selenium selenium-webdriver microstrategy

我想识别该子属于多个具有相同类名mstrmojo-DocXtabGraph的div  例如。 1. ttl ="系列:客户数量类别:东南晟价值:10,000      2. ttl ="系列:2016年营业收入平均
分类:东南晟价值:$ 883,605
%分类:

   <div id="*lK34*kW55*x1*t1494834294905" class="mstrmojo-DocXtabGraph " style="background-color: rgb(255, 255, 255); border: 1pt solid rgb(206, 206, 206); width: 614px; height: 354px; left: 34px; top: 175px; z-index: 7; display: block;">
<div class="mstrmojo-DocXtabGraph-txt" style="display: none;"></div>
<img class="mstrmojo-DocXtabGraph " usemap="#*lK34*kW55*x1*t1494834294905_map4" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmYAAAFiCAYAAABcVRQBAAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4QUPBy0Eo0d10gAAFRZJREFUeJzt3b/LG3l+B3A9wc1u3OgfeKot0mwgpBBpj4OL4QgO1xwLJj/YzuTAYAWiQAwOqIgacyGVl1xCYDkXBymuXAxXBRXBkCqsly0eME9xhcrANpPiGO94npnRzGhmvp+RXi8wK331nfl+9CDt963vjEZXWZZlCwAAkvu91AUAAPA7ghkAQBCCGQBAEIIZAEAQghkAQBCCGQBAEIIZAEAQghkAQBCCGQBAEIIZAEAQghkAQBCCGQBAEPf6bLRerxe73e5OW6782LE+XdsB4JjyXGWuYRayjp4+fZo9ffr0TlvT/aY+XdsB4JjyXGWuYS46HcqsWimr4hMHAKm0nasgok6HMpte6JaCAQBO0+scsyrl4/VThLNvv/12ce/eYE8Bg...5g7hzKBAAIQjADAAgi7KHMNj7++OPFfr+fdMy/+9HvTzrepH7096krGMWnqQsY0aefp65gPH+auoARTf3/rXP20UcfpS4BBjXrYPbpp+c85QIAl8ahTACAIK6yLMtSF1HHV54B6MrcwZyFDmYAAJfEoUwAgCAEMxjZer3+4N8p+6m6PYax9w9AtVl/KxOiq7rquCuRA1BHMIOJlX8uptxe9ZMyxdtVjx3bZ5f2/L4ACZBABozq6dOn2dOnTyvbq+63aS/vs8u2fdoBmIYVMxhZcSWseH+o/ZZVnR9WXAmra9/tdlbIABITzGAidYcqxxqnqOnw6FR1AXCcb2XCiE79duMY29d9u7NuVQ2A6VgxgxFVhZ18Var8WFV7uc+xVa2u+6zr32YsAIbnyv8AAEE4lAkAEIRgBgAQhGAGABCEYAYAEIRgBgAQhGAGABCEYAYAEIRgBgAQhGAGABCEYAYAEIRgBgAQxP8DAGsjaGrEe+gAAAAASUVORK5CYII=" hidefocus="true" style="display: block; background: transparent none repeat scroll 0% 0%;">
<map id="*lK34*kW55*x1*t1494834294905_map4" name="*lK34*kW55*x1*t1494834294905_map4">
<area shape="rect" coords="350,328,405,328" ttl="Series: Last Month's Order Count<br/>Category: Southeast<br/>Value: 9,948" aid="0" onclick="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onClickArea(this, event);" oncontextmenu="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onContextMenu(this, event);" onmousemove="mstrmojo.all['*lK34*kW55*x1*t1494834294905']._updateTooltip(event, self);">
<area shape="rect" coords="295,325,350,328" ttl="Series: Employee Headcount<br/>Category: Southeast<br/>Value: 4" aid="1" onclick="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onClickArea(this, event);" oncontextmenu="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onContextMenu(this, event);" onmousemove="mstrmojo.all['*lK34*kW55*x1*t1494834294905']._updateTooltip(event, self);">
<area shape="rect" coords="241,135,295,328" ttl="Series: Order Count<br/>Category: Southeast<br/>Value: 9,948" aid="2" onclick="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onClickArea(this, event);" oncontextmenu="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onContextMenu(this, event);" onmousemove="mstrmojo.all['*lK34*kW55*x1*t1494834294905']._updateTooltip(event, self);">
<area shape="rect" coords="186,48,241,328" ttl="Series: Item Count<br/>Category: Southeast<br/>Value: 360" aid="3" onclick="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onClickArea(this, event);" oncontextmenu="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onContextMenu(this, event);" onmousemove="mstrmojo.all['*lK34*kW55*x1*t1494834294905']._updateTooltip(event, self);">
<area shape="rect" coords="131,153,186,328" ttl="Series: Count Order shipped within 5 days<br/>Category: Southeast<br/>Value: 9034" aid="4" onclick="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onClickArea(this, event);" oncontextmenu="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onContextMenu(this, event);" onmousemove="mstrmojo.all['*lK34*kW55*x1*t1494834294905']._updateTooltip(event, self);">
<area shape="rect" coords="76,134,131,328" ttl="Series: Count of Customers<br/>Category: Southeast<br/>Value: 10,000" aid="5" onclick="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onClickArea(this, event);" oncontextmenu="mstrmojo.all['*lK34*kW55*x1*t1494834294905'].onContextMenu(this, event);" onmousemove="mstrmojo.all['*lK34*kW55*x1*t1494834294905']._updateTooltip(event, self);">
</map>
</div>

1 个答案:

答案 0 :(得分:1)

尝试跟随,使用dcssSelector识别元素,然后提取“ttl”属性:

  driver.findElement(By.cssSlector("div.mstrmojo-DocXtabGraph map area:nth-child(6)")).getAttribute("ttl");

**更新:**

  String[] data = driver.findElement(By.cssSlector("div.mstrmojo-DocXtabGraph map area:nth-child(6)")).getAttribute("ttl").split("<br/>");

然后你可以分别读取数据[0],数据[1],数据[2]以获得所需的输出。

获取第二个DIV元素:

 driver.findElement(By.cssSlector("div:nth-child(2) map area:nth-child(6)")).getAttribute("ttl");