Saturday, December 8, 2012

How to execute Compound class names using WebDriver

If you have a Compound class and you want to do something like this:
IWebElement elem = Browser.Driver.FindElement(By.ClassName("name1 name2 name 3"));

you will get an error like:
"Compound class names are not supported. Consider searching for one class name and filtering the results."

The solution:
Use CssSelector, and put "." in front of each name, like this:
IWebElement elem = Browser.Driver.FindElement(By.CssSelector(".name1.name2.name 3"));

2 comments:

  1. oh so spaces in DOM are replaced with periods? then it should be required that html be written in the same way. would help people like me understand the basics of how DOM works. thank you. i was going crazy on how figuring this out.

    ReplyDelete
    Replies
    1. correction : i was going crazy on to figure this out.... sorry about that

      Delete