-1

In my project, 2 buttons named matrix values and matrix config are shown, clicking which you will find a container of text which is displayed based on the below html scripts. My requirement is to derive the scope value based on the indexes specified in the class 'matrix-values' and with the matrix specified in the class 'matrix-config'.

<div class="preferred-matrix-debug">
<button>matrix values</button>
<button>matrix config</button>
<div class="matrix-values">{
 "e621b98a-94ea-4164-a48e-cec21b279d20": {
"matrix": {
  "costGrade": {
    "index": 6,
    "max": 545,
    "min": 45,
    "value": 208
  },
  "criticality": {
    "index": 11,
    "max": 410,
    "min": 22,
    "value": 192
  },
  "scope": "standard"
  }
}
}</div></div>

In the above script, the value of "scope" is "standard". This value is based on the "index" values(i.e. 6 and 11). As per the below matrix-config class, The value located in 6th row and 11th column is 3. The value against 3 is "standard" under matrix-config. Hence the scope is "standard".

<div class="matrix-config">
<!-- react-text: 3377 -->{
  "1": "ordinary",
  "2": "ordinary_minus",
  "3": "standard",
  "4": "standard_plus",
  "5": "standard_minus",
  "6": "low_end"
}<!-- /react-text -->
<div>0: 1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3</div>
<div>1: 1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3</div>
<div>2: 1,1,1,1,1,1,1,2,2,2,3,3,3,3,3,3,3,4,4,4</div>
<div>3: 1,1,1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,4,4,4</div>
<div>4: 1,1,1,1,1,1,2,2,2,3,3,3,3,3,3,3,3,4,4,4</div>
<div>5: 1,1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4</div>
<div>6: 1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4</div>
<div>7: 1,1,1,1,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4</div>
<div>8: 1,1,1,1,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4</div>
<div>9: 1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,5,5,5</div>
<div>10: 1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,5,5,5</div>
<div>11: 2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,5,5,5</div>
<div>12: 2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,5,5,5</div>
<div>13: 2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,5,5,5,5,5</div>
<div>14: 2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,5,5,5,5,5</div>
<div>15: 2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5</div>
<div>16: 2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,5,5,5,5,6</div>
<div>17: 2,2,3,3,3,3,3,3,3,3,4,4,4,5,5,5,5,5,6,6</div>
<div>18: 2,2,3,3,3,3,3,3,3,3,4,4,4,5,5,5,5,6,6,6</div>
<div>19: 2,2,3,3,3,3,3,3,4,4,4,4,4,5,5,5,5,6,6,6</div></div>

I would like to know whether validating the 'scope' can be achieved through selenium and java. If not atleast upto what level I can reach. Please suggest me.

Roja
  • 293
  • 1
  • 5
  • 21

1 Answers1

1

Selenium is essentially the Browser Automation tool and it is possible to use it in your case. You will have to use Selenium to read text from tags and then work with text in Java to sort out what this text contains.

So essentially Selenium does a small job here, the complexity lies in parsing a text.

You may use something like this algorithm:

  • Read div without classes and store they value into some collection, for instance, List
  • Parse string into some object (the structure of a text is pretty straight forward, so parsing should not be too difficult even with standard Jav lib)
  • Get text from div with class="matrix-config" and parse it as Json (you may try Gson library for it)
  • Once you have all data parsed you just need to compare values.

Does it help?

Alexander Pushkarev
  • 1,075
  • 6
  • 19