Reputation: 1127
I know that selenium can use css locators.
I know that the syntax is something like this:
xpath=//div[@id,'topLeft')//span[contains(@class,'name')]
or
css=#topLeft .name
Now, what if .name is like this: //span[contains(@class,'name with space')]
Then it would fail... HOw to look for a locator that has space in it?
Thanks!
EDIT Solution: css=span.name.with.space
Upvotes: 5
Views: 4729
Reputation: 4078
Class names can't have spaces. However, you can define multiple classes for a single element by putting a space between them. Take a look at the id and class identifiers section in the HTML spec for more.
You should be able to use the CSS locator by using only one of the classes.
If that doesn't work, double check your CSS selector using a tool like Firefinder for FireBug. I was able use Selenium-IDE with an element that had two classes. For the HTML
<div class="c1 c2">
<span class"s1">Test</span>
</div>
I used the selector
css=div.c1 span
Upvotes: 5