Extracting the variable from the website


#1

I need to somehow extract the variable “3990.00” from the website without using the ID. (Because it constantly changes)

I am struggling with writing the command.
For getting it by ID the target would be “id=salesprice-DB0546”
What should I type to get it by class?
Thank you!
image


#2

I assume some part of the ID stays constant? If so, then you can use this solution: https://a9t9.com/kantu/docs/selenium-ide/click#changingid

See also this forum post here: How get Kantu to work with dynamic ID's


#3

Oh, and I noticed another issue with your code: To extract a value from a website (web scraping) you need to use use storeText or storeValue, but not storeEval).


#4

Thank you so much! Fixed it.
Also, do you by any chance know how to convert “3.990” into the value 3990?
I am using the method StoreText as you suggested and this is what Kantu shows me in variables.


Should I ignore those quotes? Is it still a value or it has been extracted as a string?
I am multiplying this number by 2 later on in the macro, but it gives me an error. Im probably using the wrong syntax.
image

Thank you!


#5

To access the value of the variable, you need to use ${salesprice}.

At this point, it is a string. If you need it to be a number, please use parseFloat("${salesprice}") or parseInt("${salesprice}").


#6

I did a workaround by copying the variable onto the clipboard, then pasting it and editing it using Xkeys to remove the period and comma.

{
  "Command": "storeText",
  "Target": "//*[@id=\"page_content\"]/div/div/div[2]/div[1]/div[2]/div[1]/span[1]",
  "Value": "RAW_USD"
},
{
  "Command": "selectWindow",
  "Target": "TAB=OPEN",
  "Value": "https://the-internet.herokuapp.com/forgot_password"
},
{
  "Command": "sendKeys",
  "Target": "id=email",
  "Value": "${Raw_USD}"
},
{
  "Command": "sendKeys",
  "Target": "id=email",
  "Value": "${KEY_BACKSPACE}"
},
{
  "Command": "sendKeys",
  "Target": "id=email",
  "Value": "${KEY_BACKSPACE}"
},
{
  "Command": "sendKeys",
  "Target": "id=email",
  "Value": "${KEY_BACKSPACE}"
},
{
  "Command": "sendKeys",
  "Target": "id=email",
  "Value": "${KEY_BACKSPACE}"
},
{
  "Command": "sendKeys",
  "Target": "id=email",
  "Value": "${KEY_LEFT}"
},
{
  "Command": "XType",
  "Target": "${KEY_LEFT}",
  "Value": ""
},
{
  "Command": "XType",
  "Target": "${KEY_LEFT}",
  "Value": ""
},
{
  "Command": "XType",
  "Target": "${KEY_LEFT}",
  "Value": ""
},
{
  "Command": "XType",
  "Target": "${KEY_LEFT}",
  "Value": ""
},
{
  "Command": "XType",
  "Target": "${KEY_LEFT}",
  "Value": ""
},
{
  "Command": "XType",
  "Target": "${KEY_BKSP}",
  "Value": ""
},
{
  "Command": "XType",
  "Target": "${KEY_CTRL+KEY_A}",
  "Value": ""
},
{
  "Command": "XType",
  "Target": "${KEY_CTRL+KEY_C}",
  "Value": ""
},
{
  "Command": "store",
  "Target": "${!clipboard}",
  "Value": "USD"
},