Selenium 需要帮助来选择一个div吗

Selenium 需要帮助来选择一个div吗,selenium,selenium-webdriver,Selenium,Selenium Webdriver,我需要通过单击下拉列表中的“C”进行选择,并在移到C元素时进行选择 它的类被更改为x-combo-list-item x-combo-selected,当我在代码中使用此代码来单击元素时 drivefindElement(By.className("x-combo-list-item x-combo-selected")).click(); 它抛出一个异常 org.openqa.selenium.IllegalLocatorException: Compound class names are

我需要通过单击
下拉列表中的“C”进行选择,并在移到
C
元素时进行选择

它的类被更改为
x-combo-list-item x-combo-selected
,当我在代码中使用此代码来单击元素时

drivefindElement(By.className("x-combo-list-item x-combo-selected")).click();
它抛出一个异常

org.openqa.selenium.IllegalLocatorException: Compound class names are not supported. 
Consider searching for one class name and filtering the results.
你能帮我找到点击这个元素的方法吗

html代码。。来自萤火虫

<--div id="xyz" class="x-combo-list-inner" style="width: 253px; height: 105px;">

<--div class="x-combo-list-item" ext:qtip="">A<--/div>

<--div class="x-combo-list-item" ext:qtip="">B<--/div>

<--div class="x-combo-list-item x-combo-selected" ext:qtip="">C<--/div>

<--div class="x-combo-list-item" ext:qtip="">D<--/div>

<--div class="x-combo-list-item" ext:qtip="">E<--/div>

<--/div>

A.
B
C
D
E

考虑将选择器更改为xpath:

driver.findElement(By.xpath("//div[@class='x-combo-list-item x-combo-selected']")).click();

由于网页上有多个元素的类名为“x-combo-list-item x-combo-selected”,因此可能会出现此错误

您还可以通过安装firefox插件并尝试代码中使用的xpath来验证这一点

在firepath的帮助下,尝试找到您正试图单击的正确WebElement。在firebug的帮助下,您甚至可以通过右键单击WebElement并复制XPath来获取页面上元素的XPath