Search code examples
vbaselenium-webdriverxpathcss-selectorswebdriver

Findelement "Run-time error '32' "Compound Class names not permitted"


I am trying to automatically run a program to compare mortgage insurance from various companies.

I need to hit a "Submit" button to get the mortgage insurance amounts. The program I use stalls at this screen, instead of "auto-clicking" to the next screen.

This is what the code looks like:

<button class="full-width ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" pbutton="" type="submit"><span class="ui-button-text ui-clickable">Order Quotes</span></button>
<span class="ui-button-text ui-clickable">Order Quotes</span>

The part that says <span class> I know is the key to this. But the area above it also has something to do with it because when I hover over the button, there are two ways the button is "emphasized". The top codes darkens the whole button. Whereas the bottom code only highlights the wording inside the button.

I tried the following code(s)

Driver.FindElementsByClass("ui-button-text ui-clickable").Click

I get

Run-time error '32' "Compound Class names not permitted"

Driver.FindElementsByClass("full-width ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only").Click

I get the same "Run-time error '32'" message as above.

I have other items in this program with a .click after the line and it works.


Solution

  • Run-time error '32' message saying "Compound Class names not permitted the error suggested that FindElementsByClass() doesn't support multiple class names it supports only class name

    You can either pass single class only in FindElementsByClass() or use FindElementByCss() or FindElementByXPath()

    Option 1:

     Driver.FindElementsByClass("ui-button-text").Click
    

    Option 2:

     Driver.FindElementByCss(".ui-button-text.ui-clickable").Click
    

    Option 3:

    Driver.FindElementByXPath("//span[text()='Order Quotes']").Click