On the website https://www.steelmint.com/crc-prices-global 2 I am unable to select the text “FOB Black Sea”.
The xpath is //*[@id=“tblPrices_E_I_”]/tbody/tr[1]/td[1]
But this xpath contains a span and div elements and displays the value of the div element (“W”)
Similarly, on another website I am unable to select text as it contains newline characters.
Attached is the json for this job
I think I have manged to get the code formatting correct this time. I tried running it again to be extra sure.
On both the websites we face the same issue. Chrome developer tool shows the text being correctly selected by the xpath but we are unable to get the text into a variable.
Thanks for the input. Unfortunately sourceExtract will not work in my case. I need a method to be able to extract all elements of the table. I was hoping that something along the lines of storeEval | x = document.getElementById("/html/body/table/tbody/tr[2]/td[3]").text() | myval
I have tried the storeEval for the second issue (source json is in the message). The above does not work, but is something along the same lines possible? It would be of great help.
I was able to get sourceExtract to work. This is with regards to the above pasted code. The variable now contains the desired value along with extra characters that need to be removed. I am unable to remove the extra characters due to the presence of "\n". I have found this related to the following post storeEval Javascript [error] Error in runEval code: Invalid or unexpected token
sourceExtract | VERTICAL-ALIGNfont size\n*@3 | rawName
rawname contains “<td style="VERTICAL-ALIGN: top"><font size="2">\n SEMI-FINISHED PRODUCTS OF IRON OR NON- ALLOY STEEL”
Many thanks!! I did not know about regex lookaround (Lookahead and Lookbehind). With your help I was able to write a correct regex to filter and get only the desired part of the string.
Attaching the working and corrected code for reference of others like me.