Search code examples
javascriptxpathtextextractimacros

(Imacross) Extract Text from _Xpath_ no extract content from Class under Javascript


Using this code under imacros 9.0.3 running on Firefox 55 works very well extracting the text from the class

TAG XPATH="//div[contains(@class,'col-md-12 text-center alert alert-danger')]" EXTRACT=TXT

But if you implement the same situation on Javascript Running Imacros, it stops working

var macro;
macro = "CODE:";

macro += "TAG XPATH="//div[contains(@class,'col-md-12 text-center alert alert-danger')]" EXTRACT=TXT" + "\n";

iimPlay(macro)
iimDisplay(result);

I have also used in another more explicit way the location where I need to extract the content, but even so it does not work using the code in java

/html/body/div[2]/div/div[1]/div/div/div

Solution

  • Hope the following script should work:

    var macro;
    macro = "CODE:";
    
    macro += 'TAG XPATH="//div[contains(@class,\'col-md-12 text-center alert alert-danger\')]" EXTRACT=TXT' + "\n";
    
    iimPlay(macro);
    iimDisplay(iimGetExtract());