Skip to content

Instantly share code, notes, and snippets.

@matisnape
Last active March 10, 2018 15:41
Show Gist options
  • Save matisnape/7494084d592cfec0786da32f096bd753 to your computer and use it in GitHub Desktop.
Save matisnape/7494084d592cfec0786da32f096bd753 to your computer and use it in GitHub Desktop.
Get sum of PEKA tickets value
# tPortmonetka - przejazdy
# range of positions: position() >= 100 and not(position() > 200)
# get last column
let cost_col = $x("//*[@id='dataTable']//tr[position() >= 100 and not(position() > 200)]/td[last()]/div");
# parse to float
let float_cost_col = cost_col.map(el => parseFloat(el.innerText.replace(',', '.')));
# sum
let cost_sum = float_cost_col.reduce((el1, el2) => el1 + el2, 0).toFixed(2);
# oneliner
calculate = $x("//*[@id='dataTable']//tr[position()>=13]/td[last()]/div").map(el => parseFloat(el.innerText.replace(',', '.'))).reduce((el1, el2) => el1 + el2, 0).toFixed(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment