0

I'm trying to learn more about how Selenium works with VBA and I'm trying to do somethings about the trendings behaviors of ecommerce nowadays.

In this case, I don't know how works the FindelementByclass when it has special characters like _ or - inside, because it always gives me empty result and I need to identify it because I want to go through every class called as it.

<span class="minificha__sku ng-binding">Cód TG: AS0-322</span>
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
Peter
  • 31
  • 5

2 Answers2

0

space in class means it has two classes,

class="minificha__sku ng-binding"

means it has "minificha__sku" and "ng-binding" , so use xpath or css instead of byclass or use either of the two class not two

css:

span[class="minificha__sku ng-binding"]

xpath

//span[@class="minificha__sku ng-binding"]
PDHide
  • 10,919
  • 2
  • 12
  • 26
  • I understand, but it doesn't work for what I need to do, or I guess that's what's is causing issues in my script, can you give me an example using css? – Peter Feb 15 '21 at 19:00
  • Added answer please see the update – PDHide Feb 15 '21 at 19:05
  • Your css pattern is wrong as compound classes need to be joined by "." i.e. minificha__sku.ng-binding unless you intended to insert a descendant combinator in there and look for a child node? – QHarr Mar 05 '21 at 20:25
  • I didn't understand – PDHide Mar 05 '21 at 21:55
-1

To identify the element you can use either of the following Locator Strategies:

  • Using FindElementByClassName I:

    bot.FindElementByClassName("minificha__sku")
    
  • Using FindElementByClassName II:

    bot.FindElementByClassName("ng-binding")
    
  • Using FindElementByCss:

    bot.FindElementByCss("span.minificha__sku.ng-binding")
    
  • Using FindElementByXPath:

    bot.FindElementByXPath("//span[@class='minificha__sku ng-binding']")
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217