Home > Blockchain >  VBA Selenium Scraping text from label
VBA Selenium Scraping text from label

Time:07-23

How do I extract the following "label" using the chrome driver in Selenium for VBA? The information that I want is "Character 3"

HTML:

<label for="frmentermemorableinformation1:strEnterMemorableInformation_memInfo1">Character 3 &nbsp;</label>

CodePudding user response:

To print the text Character 3 you can use either of the following locator strategies:

  • Using css_selector:

    Debug.Print .FindElementByCss("label[for^='frmentermemorableinformation1'][for$='strEnterMemorableInformation_memInfo1']").Text
    
  • Using xpath:

    Debug.Print .FindElementByXPath("//label[starts-with(@for, 'frmentermemorableinformation1') and contains(@for, 'strEnterMemorableInformation_memInfo1')]").Text
    
  • Related