One of the causes of the error is when trying to get an element with a space in the class name. For example, suppose you want to get an element whose class name is "class name" as follows.
python
driver.findElements(By.className("class name"));
In Selenium, there are spaces in attribute values such as class and id. If this is left as it is, an error will occur, so You can get the element by specifying the cssSelector element with a slightly different description method. The description format is
tag name
} [{ attribute name
} ='{ attribute value
}'] ");python
driver.findElement(By.cssSelector("div[class='class name']"));
You can get the element by describing the tag name, attribute name, and attribute value using cssSelector.
that's all.
Recommended Posts