我使用硒standalon-2.25.0和Chrome的版本是13RemoteDriver使用Chrome瀏覽器下拉菜單上失敗
下面是HTML:
<select name="suffix" class="select">
<option value="" selected>Please select...</option>
<option value="Ms.">Ms.</option>
<option value="Mrs.">Mrs.</option>
<option value="Mr.">Mr.</option>
</select>
這裏是我的命令打電話選擇其中一個選項。另一個是我從數據庫中獲取的變量,問題是我從數據庫中獲取的後綴。這在Firefox和IE,但不是鍍鉻:
driver.findElement(By.xpath("//option[@value='" + other + "' and ..[@name='" + question + "']]")).click();
這是我得到的例外:我一直在這一段時間
org.openqa.selenium.InvalidSelectorException: findElement execution failed;
Unable to locate an element with the xpath expression //option[@value='Ms.' and ..[@name='suffix']] because of the following error:
Error: INVALID_EXPRESSION_ERR: DOM XPath Exception 51 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 52 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_25'
Driver info: driver.version: EventFiringWebDriver
Session ID: bf6368f23db4a2fe27d9b96849af1b1d
Command duration or timeout: 646 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-31-generic', java.version: '1.6.0_31'
Driver info: driver.version: RemoteWebDriver
Session ID: 134947044387
,我的猜測是爲有用我的findElement語句做。奇怪的部分是,這是FF和IE工作正常。任何幫助將非常感激。再次感謝。
布萊恩
感謝艾倫就是這樣。我不知道爲什麼我決定上樹而不是下樹。其實我甚至感到驚訝它在FF和IE中工作。 –