Select a button by Class

Hi, I need to click to a button.
The html code hasn’t button ID but I found this:

<button class="btn btn-primario btn-lg  btn-block colorButtonBlue fontWhite voffset3" style="width:100%;color:white;text-align:center" data-ng-click="login()">
                                    <!-- ngIf: language!='en' --><span data-ng-if="language!='en'" class="ng-scope" style="">ACCEDI</span><!-- end ngIf: language!='en' -->
                                    <!-- ngIf: language=='en' -->

I tried to insert this instruction in my code by PyCharm

driver.find_element(By.CLASS_NAME, "btn btn-primario btn-lg  btn-block colorButtonBlue fontWhite voffset3")

but it return me
Unable to locate element: {“method”:“css selector”,“selector”:“.btn btn-primario btn-lg btn-block colorButtonBlue fontWhite voffset3”}

  • (Session info: chrome=106.0.5249.119)*

Can someone help me please??

CSS classes are all separate. The button you’re looking at has all of these:

  • btn
  • btn-primario
  • btn-lg
  • btn-block
  • colorButtonBlue
  • fontWhite
  • voffset3

To select that buttn, you would have to ask for a button that fits multiple selectors. I’m not sure which ones are important here (for instance, I suspect that fontWhite and colorButtonBlue are purely visual), but let’s say you want to pick up a button with both the btn-primario and btn-lg classes. That would be a selector .btn-primario and a selector .btn-lg, and then you stick those together without a separator to say that the same thing has to have BOTH classes:


By the way, this isn’t a core Python feature. It’s helpful, when asking questions like this, to say exactly what tool or library you’re using when this happens. (I happen to be able to make a pretty good guess in this case, but it’s definitely best to say outright what it is.)

Good luck!